public static CoQuanBanHanhVanBanInfo ToDataInfo(this CoQuanBanHanhVanBanResult entity) { return(new CoQuanBanHanhVanBanInfo { Id = entity.Id, Name = entity.Ten }); }
public SaveResult Delete(CoQuanBanHanhVanBanResult entity) { return(ExecuteDbWithHandle(_logService, () => { using (var context = new TechOfficeEntities()) { var cv = context.CoQuanBanHanhVanBans.Single(x => x.Id == entity.Id && x.IsDeleted == false); cv.IsDeleted = true; cv.LastUpdatedBy = entity.LastUpdatedBy; cv.LastUpdated = DateTime.Now; context.Entry(cv).State = EntityState.Modified; return context.SaveChanges() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public async Task <SaveResult> AddAsync(CoQuanBanHanhVanBanResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var add = context.CoQuanBanHanhVanBans.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(CoQuanBanHanhVanBanResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var update = context.CoQuanBanHanhVanBans.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; } })); }
public static CoQuanBanHanhVanBanInfo ToIfNotNullDataInfo(this CoQuanBanHanhVanBanResult entity) { return(entity?.ToDataInfo()); }