コード例 #1
0
        public void Delete(int id)
        {
            using var trans = repoService.DbContext.Database.BeginTransaction();
            var dbBackupEntity = repoService.FindOne(id);

            if (dbBackupEntity != null)
            {
                hostingEnvironment.DeleteFile(dbBackupEntity.FilePath);
                repoService.Delete(dbBackupEntity);
            }

            trans.Commit();
        }
コード例 #2
0
        public IActionResult Update(int id, string name, int cat, int?parent)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(Error("组织名不能为空!"));
            }

            if (cat == 0)
            {
                return(Error("组织分类不能为空!"));
            }

            OrganizeEntity?parentEntity = null;

            if ((parent ?? 0) != 0)
            {
                parentEntity = repoService.FindOne(parent !.Value);
                if (parentEntity == null)
                {
                    return(Error("父组织不存在"));
                }
            }

            if (catService.FindOne(cat) == null)
            {
                return(Error("组织类别不存在"));
            }

            repoService.Update(new OrganizeEntity
            {
                Id = id, CategoryId = cat, Name = name, ParentId = parent
            });
            return(Success());
        }
コード例 #3
0
        private object entityToModel(ApprovalInstanceEntity it)
        {
            var ids           = it.InfoInstances.Split(",", StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToList();
            var infoInstances = infoInstanceService.IQueryable().Where(it => ids.Contains(it.Id)).ToList();

            return(new
            {
                id = it.Id,
                desc = it.Description,
                prototype = it.AppprovalTable.Name,
                values = infoInstances.Select(info =>
                {
                    var infoClass = infoClassService.FindOne(info.PrototypeId) !;
                    return new
                    {
                        id = info.Id,
                        prototypeId = infoClass.Id,
                        name = infoClass.Name,
                        type = infoClass.InputType,
                        value = info.Value,
                        status = info.Status
                    };
                }),
                creator = it.CreatorUser?.RealName,
                modifer = it.LastModifyUser?.RealName,
                state = it.State
            });
コード例 #4
0
        public IActionResult Delete(int id)
        {
            var user = GetUserInformation();
            var ins  = repoService.FindOne(id);

            if (ins == null)
            {
                throw new Exception("信息不存在!");
            }
            if (ins.User.Id != user.Id && !user.IsAdmin)
            {
                throw new Exception("权限不足!");
            }
            repoService.Delete(ins);
            return(Success());
        }
コード例 #5
0
        public IActionResult One(int id)
        {
            var datas = repoService.FindOne(id);

            if (datas == null)
            {
                throw new Exception("组织类型不存在!");
            }
            return(Success(new OrganizeCategoryModel().FromEntity(datas)));
        }
コード例 #6
0
        public IActionResult Update([FromBody] UserOrganizeModel userOrganizeModel)
        {
            UserOrganizeEntity entity = new()
            {
                Id        = userOrganizeModel.Id,
                User      = userService.FindOne(userOrganizeModel.UserId),
                Organize  = organizeService.FindOne(userOrganizeModel.OrganizeId),
                DutyLevel = userOrganizeModel.DutyLevel
            };

            repoService.Update(entity);
            return(Success());
        }
コード例 #7
0
        public IActionResult Index()
        {
            var user = GetUserInformation();
            var data = repoService
                       .IQueryable()
                       .Where(it => it.User.Id == user.Id)
                       .ToList().Select(it =>
            {
                var model       = new InfoInstanceModel().FromEntity(it);
                model.InfoClass = new InfoClassModel().FromEntity(infoClassService.FindOne(it.PrototypeId) !);
                return(model);
            });

            return(Success(data));
        }
コード例 #8
0
        public IActionResult Update([FromBody] RoleModel roleModel)
        {
            var cat = roleModel.OrganizeCategoryId;

            if (cat == 0)
            {
                return(Error("组织类型不能为空!"));
            }

            if (catService.FindOne(cat) == null)
            {
                return(Error("组织类型不存在!"));
            }

            var menus     = roleModel.AvailableMenus?.ToList() ?? new List <string>();
            var approvals = roleModel.AvailableApprovals?.ToList() ?? new List <string>();

            if (menus.Any(string.IsNullOrWhiteSpace))
            {
                return(Error("菜单类型错误!"));
            }

            if (approvals.Any(string.IsNullOrWhiteSpace))
            {
                return(Error("审批类型错误!"));
            }

            var roleEntity = new RoleEntity
            {
                Id                 = roleModel.Id,
                Name               = roleModel.Name !,
                Description        = roleModel.Description ?? "",
                OrganizeCategoryId = roleModel.OrganizeCategoryId,
                OrganizeDutyLevel  = roleModel.OrganizeDutyLevel !.Value,
                AvailableMenus     = "," + string.Join(",", menus) + ",",
                AvailableApprovals = "," + string.Join(",", approvals) + ","
            };

            repoService.Update(roleEntity);

            return(Success());
        }
コード例 #9
0
 public UserEntity FindOne(int id)
 {
     return(service.FindOne(id));
 }
コード例 #10
0
        public IActionResult FindOne(int id)
        {
            var data = new ApprovalTableModel().FromEntity(repoService.FindOne(id));

            return(Success(data));
        }