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(); }
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()); }
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 });
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()); }
public IActionResult One(int id) { var datas = repoService.FindOne(id); if (datas == null) { throw new Exception("组织类型不存在!"); } return(Success(new OrganizeCategoryModel().FromEntity(datas))); }
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()); }
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)); }
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()); }
public UserEntity FindOne(int id) { return(service.FindOne(id)); }
public IActionResult FindOne(int id) { var data = new ApprovalTableModel().FromEntity(repoService.FindOne(id)); return(Success(data)); }