public async Task <IActionResult> CerateOrEdit([FromBody] ESysRole eSysRole) { bool flag = false; try { if (eSysRole.RoleID == 0) { using (var uow = _uowFactory.Create()) { flag = await _SysRoleRepository.AddAsync(eSysRole); 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 _SysRoleRepository.UpdateAsync(eSysRole); 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(ESysRole eSysRole) { string sql = "update Sys_Role set RoleName=@RoleName,Status=@Status,Mark=@Mark where RoleID=@RoleID;"; return(await _context.ExecuteAsync(sql, eSysRole) > 0); }
public async Task <bool> AddAsync(ESysRole eSysRole) { string sql = "insert into Sys_Role(RoleName,Status,Mark) values(@RoleName,@Status,@Mark);select @@Identity;"; return(await _context.ExecuteAsync(sql, eSysRole) > 0); }