/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <FuncResult> Update(int id, SysModelGroupModel model, int currentuserId) { var entity = await _context.SysModelGroups.FindAsync(id); if (entity == null) { return(new FuncResult() { IsSuccess = false, Message = "用户ID错误!" }); } entity.Model_Group_Code = model.ModelGroupCode; entity.Model_Group_Name = model.ModelGroupName; entity.Parent_Id = model.ParentId; entity.Sort_Flag = model.SortFlag; entity.Enable_Flag = model.EnableFlag; entity.Image_Url = model.ImageUrl; entity.Group_Belong = model.GroupBelong; entity.Biz_Sys_Code = model.BizSysCode; entity.Last_Updated_By = currentuserId; entity.Last_Update_Date = DateTime.Now; _context.SysModelGroups.Update(entity); await _context.SaveChangesAsync(); return(new FuncResult() { IsSuccess = true, Content = entity, Message = "修改成功" }); }
public async Task <FuncResult> Add([FromBody] SysModelGroupModel model) { if (!ModelState.IsValid) { return(new FuncResult() { IsSuccess = false, Message = "参数错误" }); } return(await sysModelGroupBLL.Add(model, CurrentUser.Get().Id)); }
public async Task <FuncResult> Add(SysModelGroupModel model, int currentUserId) { var entity = new SysModelGroup() { Model_Group_Code = model.ModelGroupCode, Model_Group_Name = model.ModelGroupName, Parent_Id = model.ParentId, Sort_Flag = model.SortFlag, Enable_Flag = model.EnableFlag, Image_Url = model.ImageUrl, Group_Belong = model.GroupBelong, Biz_Sys_Code = model.BizSysCode, Last_Updated_By = currentUserId, Last_Update_Date = DateTime.Now, Created_By = currentUserId, Creation_Date = DateTime.Now }; await _context.SysModelGroups.AddAsync(entity); using (Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction trans = _context.Database.BeginTransaction()) { try { await _context.SaveChangesAsync(); trans.Commit(); } catch (Exception ex) { trans.Rollback(); return(new FuncResult() { IsSuccess = false, Content = ex.Message }); } } return(new FuncResult() { IsSuccess = true, Content = entity, Message = "添加成功" }); }
public async Task <FuncResult> Update(int id, [FromBody] SysModelGroupModel model) { FuncResult data = await sysModelGroupBLL.Update(id, model, CurrentUser.Get().Id); return(data); }