public async Task <IActionResult> CerateOrEdit([FromBody] ESysMenu eSysMenu) { bool flag = false; try { if (eSysMenu.MenuID == 0) { using (var uow = _uowFactory.Create()) { flag = await _SysMenuRepository.AddAsync(eSysMenu); uow.SaveChanges(); } if (flag) { return(Ok(new { status = true, message = "success" })); } else { return(Ok(new { status = false, message = "error" })); } } else { using (var uow = _uowFactory.Create()) { flag = await _SysMenuRepository.UpdateAsync(eSysMenu); uow.SaveChanges(); } if (flag) { return(Ok(new { status = true, message = "success" })); } else { return(Ok(new { status = false, message = "error" })); } } } catch (Exception ex) { return(Ok(new { status = false, message = ex.Message })); } }
public async Task <bool> UpdateAsync(ESysMenu eSysMenu) { string sql = "update Sys_Menu set MenuTitle=@MenuTitle,MenuUrl=@MenuUrl,ParentID=@ParentID,Style=@Style,Sort=@Sort,Status=@Status where MenuID=@MenuID;"; return(await _context.ExecuteAsync(sql, eSysMenu) > 0); }
public async Task <bool> AddAsync(ESysMenu eSysMenu) { string sql = "insert into Sys_Menu(MenuTitle,MenuUrl,ParentID,Style,Sort,Status) values(@MenuTitle,@MenuUrl,@ParentID,@Style,@Sort,@Status);select @@Identity;"; return(await _context.ExecuteAsync(sql, eSysMenu) > 0); }