public async Task <IActionResult> Add(Roles roles) { bool res = false; roles.UpdateDate = DateTime.Now; if (roles.Id > 0) { res = await _rolesServices.Update(roles); } else { var data = await _rolesServices.QueryByClause(m => m.RoleName == roles.RoleName); if (data != null) { return(Error(roles.RoleName + "已经存在!")); } res = await _rolesServices.Add(roles); } if (res) { return(Success("保存成功")); } else { return(Error("保存失败")); } }
public async Task <IActionResult> Post([FromBody] RolesDTO rolesDto) { var role = _mapper.Map <Roles>(rolesDto); await _rolesServices.Add(role); rolesDto = _mapper.Map <RolesDTO>(role); var response = new GenericResponse <RolesDTO>(rolesDto); return(Ok(response)); }