server/aspnetapp/Controllers/WebUI/DepartmentController.cs

(开头部分) 11KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using aspnetapp;
using aspnetapp.Models;
using aspnetapp.Helper;

namespace aspnetapp.Controllers.WebUI
{
    public class DepartmentController : Controller
    {
        private readonly CounterContext _context;

        public DepartmentController(CounterContext context)
        {
            _context = context;
        }

        // GET: Department
        public async Task<IActionResult> Index()
        {
            SysUserEntity userinfo = HttpContext.Session.GetObjectFromJson<SysUserEntity>("sysu") ?? new SysUserEntity();
            if (userinfo.UserType == (int)EnumCode.UserType.订餐管理员)
            {
                BuyrUserEntity thispayuser = await _context.BuyrUsers.FirstOrDefaultAsync(s => s.WeChatOpenid == userinfo.Wxid).ConfigureAwait(false);
                ViewBag.allcom = await _context.Companys.AsNoTracking().Where(s => s.Id == thispayuser.CompanyId).OrderBy(s => s.SortNo).ToListAsync().ConfigureAwait(false);
            }
            else
            {
                ViewBag.allcom = await _context.Companys.AsNoTracking().OrderBy(s => s.SortNo).ToListAsync().ConfigureAwait(false);
            }

            List<DepartmentEntity> alldep = await _context.Departments.OrderBy(s => s.CompanyId).ThenBy(s => s.SortNo).AsNoTracking().ToListAsync();

            if (userinfo.UserType == (int)EnumCode.UserType.订餐管理员)
            {
                BuyrUserEntity thispayuser = await _context.BuyrUsers.FirstOrDefaultAsync(s => s.WeChatOpenid == userinfo.Wxid).ConfigureAwait(false);

                ViewBag.fdep = alldep.Where(s => s.ParentUnid == null && s.CompanyId == thispayuser.CompanyId).OrderBy(s => s.SortNo).ToList();

                alldep = alldep.Where(s => s.CompanyId == thispayuser.CompanyId).ToList();
            }
            else
            {
                ViewBag.fdep = alldep.Where(s => s.ParentUnid == null).OrderBy(s => s.SortNo).ToList();
            }

            return View(alldep);
        }

        // GET: Department/Details/5
        public async Task<IActionResult> Details(int? id)
        {
            if (id == null)
            {
后面还有 229 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。