예제 #1
0
        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());
        }
예제 #2
0
        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);
        }
예제 #3
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();
        }
예제 #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 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());
        }
예제 #7
0
 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());
 }