public static LinhVucThuTucInfo ToDataInfo(this LinhVucThuTucResult entity) { return(new LinhVucThuTucInfo { Id = entity.Id, Name = entity.Ten }); }
public async Task <SaveResult> AddAsync(LinhVucThuTucResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { entity.AddToDb(context); return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public SaveResult Add(LinhVucThuTucResult entity) { return(ExecuteDbWithHandle(_logService, () => { using (var context = new TechOfficeEntities()) { entity.AddToDb(context); return context.SaveChanges() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public static void UpdateToDb(this LinhVucThuTuc entity, LinhVucThuTucResult data, DbContext context) { entity.Ten = data.Ten; entity.MoTa = data.MoTa; entity.ParentId = data.ParentId; entity.IsDeleted = data.IsDeleted; entity.LastUpdatedBy = data.LastUpdatedBy; entity.LastUpdated = DateTime.Now; context.Entry(entity).State = EntityState.Modified; }
public async Task <SaveResult> DeleteAsync(LinhVucThuTucResult entity) { return(await ExecuteDbWithHandleAsync(_logService, async() => { using (var context = new TechOfficeEntities()) { var tt = context.LinhVucThuTucs.Single(x => x.Id == entity.Id && x.IsDeleted == false); tt.DeleteToDb(context, entity.LastUpdatedBy); return await context.SaveChangesAsync() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public SaveResult Update(LinhVucThuTucResult entity) { return(ExecuteDbWithHandle(_logService, () => { using (var context = new TechOfficeEntities()) { var update = context.LinhVucThuTucs.Single(x => x.Id == entity.Id && x.IsDeleted == false); update.UpdateToDb(entity, context); return context.SaveChanges() > 0 ? SaveResult.SUCCESS : SaveResult.FAILURE; } })); }
public static void AddToDb(this LinhVucThuTucResult entity, TechOfficeEntities context) { var add = context.LinhVucThuTucs.Create(); add.Ten = entity.Ten; add.MoTa = entity.MoTa; add.ParentId = entity.ParentId; add.IsDeleted = entity.IsDeleted; add.CreatedBy = entity.CreatedBy; add.CreateDate = DateTime.Now; context.Entry(add).State = EntityState.Added; }
public static LinhVucThuTucViewModel ToDataViewModel(this LinhVucThuTucResult entity) { return(new LinhVucThuTucViewModel { Id = entity.Id, Name = entity.Ten, ParentId = entity.ParentId, Description = entity.MoTa, CreateDate = entity.CreateDate, CreatedBy = entity.CreatedBy, IsDeleted = entity.IsDeleted, LastUpdated = entity.LastUpdated, LastUpdatedBy = entity.LastUpdatedBy }); }
private string GetNameMultiple(LinhVucThuTucResult thutuc) { var result = string.Empty; if (thutuc == null) { return(string.Empty); } if (thutuc.ParentId == 0) { return(result); } var temp = _listLinhVucThuTuc.Where(x => x.Id == thutuc.ParentId).SingleOrDefault(); result = GetNameMultiple(temp) + String.Format("{0}", "\xA0\xA0\xA0\xA0\xA0"); return(result); }
private string GetNameMultiple(LinhVucThuTucResult thutuc) { if (thutuc == null) { return(string.Empty); } var result = thutuc.Ten; if (thutuc.ParentId == 0) { return(result); } var temp = _listLinhVucThuTuc.Where(x => x.Id == thutuc.ParentId).SingleOrDefault(); result = GetNameMultiple(temp) + " >> " + thutuc.Ten; return(result); }
public static LinhVucThuTucInfo ToIfNotNullDataInfo(this LinhVucThuTucResult entity) { return(entity?.ToDataInfo()); }
public static LinhVucThuTucViewModel ToIfNotNullDataViewModel(this LinhVucThuTucResult entity) { return(entity?.ToDataViewModel()); }