public IActionResult Delete([FromBody] int[] ids) { using var trans = repoService.DbContext.Database.BeginTransaction(); foreach (var id in ids) { repoService.Delete(id); } trans.Commit(); return(Success()); }
public void CreateAndDeleteRepository() { // Arrange var repoService = new RepoService(new MockRepoRepository()); // Act var createdRepoId = repoService.Create("repo"); var deletionResult = repoService.Delete(createdRepoId); // Assert Assert.IsTrue(deletionResult); }
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 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 void RemoveLog(string keepTime) { DateTime operateTime = DateTime.Now; if (keepTime == "7") //保留近一周 { operateTime = DateTime.Now.AddDays(-7); } else if (keepTime == "1") //保留近一个月 { operateTime = DateTime.Now.AddMonths(-1); } else if (keepTime == "3") //保留近三个月 { operateTime = DateTime.Now.AddMonths(-3); } repoService.Delete(it => it.Date <= operateTime); }
public IActionResult Update([FromBody] ApprovalTableModel approvalTable) { using var trans = repoService.DbContext.Database.BeginTransaction(); var orgIds = approvalTable.OwnerOrganizes ?? new List <int>(); var orgs = organizeService.IQueryable().Where(it => orgIds.Contains(it.Id)).ToList(); if (orgs.Count != orgIds.Count) { throw new Exception("组织不存在!"); } var infoClassIds = approvalTable.InfoClasses ?? new List <int>(); var infoClasses = infoClassService.IQueryable().Where(it => infoClassIds.Contains(it.Id)).ToList(); if (infoClassIds.Count != infoClasses.Count) { throw new Exception("类型不存在!"); } var entity = approvalTable.ToEntity(); repoService.Update(entity); tableInfoClassService.Delete(it => it.ApprovalTable.Id == entity.Id); tableOrganizeService.Delete(it => it.ApprovalTable.Id == entity.Id); foreach (var infoClassEntity in infoClasses) { tableInfoClassService.Update(new ApprovalTableInfoClassEntity { ApprovalTable = entity, InfoClass = infoClassEntity }); } foreach (var organizeEntity in orgs) { tableOrganizeService.Update(new ApprovalTableOrganizeEntity { ApprovalTable = entity, Organize = organizeEntity }); } trans.Commit(); return(Success()); }
public void Delete(int id) { service.Delete(id); }
public IActionResult Delete(int id) { repoService.Delete(id); return(Success()); }
public IActionResult Delete(int id) { organizeService.Delete(id); return(Success()); }