protected Group Transfor(EF_Group DataEntry) { return(new Group() { Id = DataEntry.Id, GroupName = DataEntry.GroupName, Desc = DataEntry.Desc, CreateDate = DataEntry.CreateDate, ModifyDate = DataEntry.ModifyDate }); }
public async Task <RS_Object> UpdateGroup(EF_Group DataEntry) { RS_Object result = new RS_Object(); try { var Rs_Modify = await this.Daogroup.UpdateGroup(DataEntry); Rs_Modify.Message = Rs_Modify.Success ? $"成功更新群組資料{Rs_Modify.Count}筆" : Rs_Modify.Message; result = Rs_Modify.Transfor("群組"); return(result); } catch (Exception ex) { Nlogger.WriteLog(Nlogger.NType.Error, $"{ex.Message}{ex.InnerException}", ex); } return(result); }
public async Task <RS_ModifyResult> CreateGroup(EF_Group DataEntry) { RS_ModifyResult result = new RS_ModifyResult("Add"); try { this.dbcontext.Group.Add(this.Transfor(DataEntry)); var SaveResult = await this.dbcontext.SaveChangesAsync(); result.Count = SaveResult; result.Success = true; } catch (Exception ex) { result.Message = ex.ToString(); result.Success = false; Nlogger.WriteLog(Nlogger.NType.Error, ex.Message, ex); } return(result); }
public async Task <RS_ModifyResult> UpdateGroup(EF_Group DataEntry) { RS_ModifyResult result = new RS_ModifyResult("Update"); try { var clone = this.Transfor(DataEntry); var ef_find = await this.dbcontext.Group.FirstAsync(b => b.Id == DataEntry.Id); this.dbcontext.Entry(ef_find).CurrentValues.SetValues(clone); this.dbcontext.Group.Update(ef_find); var SaveResult = await this.dbcontext.SaveChangesAsync(); result.Count = SaveResult; result.Success = true; } catch (Exception ex) { result.Message = ex.ToString(); result.Success = false; Nlogger.WriteLog(Nlogger.NType.Error, ex.Message, ex); } return(result); }
public async Task <RS_Object> UpdateGroup(EF_Group DataEntry) { return(await this.group.UpdateGroup(DataEntry)); }