public SaveResult Delete(MucDoHoanThanhResult entity) { return(ExecuteDbWithHandle(_logService, () => { using (var context = new TechOfficeEntities()) { var ht = context.MucDoHoanThanhs.Single(x => x.Id == entity.Id && x.IsDeleted == false); ht.IsDeleted = true; ht.LastUpdatedBy = entity.LastUpdatedBy; ht.LastUpdated = DateTime.Now; context.Entry(ht).State = EntityState.Modified; return context.SaveChanges() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public async Task <SaveResult> AddAsync(MucDoHoanThanhResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var add = context.MucDoHoanThanhs.Create(); add.Ten = entity.Ten; add.MoTa = entity.MoTa; add.IsDeleted = entity.IsDeleted; add.CreatedBy = entity.CreatedBy; add.CreateDate = DateTime.Now; context.Entry(add).State = EntityState.Added; return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public async Task <SaveResult> UpdateAsync(MucDoHoanThanhResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var update = context.MucDoHoanThanhs.Single(x => x.Id == entity.Id && x.IsDeleted == false); update.Ten = entity.Ten; update.MoTa = entity.MoTa; update.IsDeleted = entity.IsDeleted; update.LastUpdatedBy = entity.LastUpdatedBy; update.LastUpdated = DateTime.Now; context.Entry(update).State = EntityState.Modified; return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }