public async Task <GenericResponse <RoleDto> > Get(long id) { RoleBo bo = null; ServiceResult <RoleBo> result = await serviceManager.Role_Service.GetByIdAsync(id); if (result.Success) { bo = result.Data; } else { //Log(result.Error, LogLevel.Error, this.ControllerContext.RouteData.Values); } if (bo == null) { return(GenericResponse <RoleDto> .Error(ResultType.Error, "Not Found!", "R_G_01", StatusCodes.Status404NotFound)); } return(GenericResponse <RoleDto> .Ok(RoleBo.ConvertToDto(bo))); }
public async Task <GenericResponse <RoleDto> > Post([FromBody] RoleDto dto) { RoleBo bo = RoleBo.ConvertToBusinessObject(dto); ServiceResult <RoleBo> result = await serviceManager.Role_Service.CreateAsync(bo); if (result.Success) { bo = result.Data; await serviceManager.CommitAsync(); } else { return(GenericResponse <RoleDto> .Error(ResultType.Error, result.Error, "R_PST_01", StatusCodes.Status500InternalServerError)); } if (bo == null) { return(GenericResponse <RoleDto> .Error(ResultType.Error, "Not Found!", "R_PST_02", StatusCodes.Status404NotFound)); } return(GenericResponse <RoleDto> .Ok(RoleBo.ConvertToDto(bo))); }