public IActionResult GetSubCategory(int id) { var subCategory = _subCategoryService.GetById(id); if (!subCategory.Success) { return(BadRequest(subCategory.Message)); } var result = _mapper.Map <SubCategoryForReturnDTO>(subCategory); return(Ok(result)); }
public async Task <IActionResult> GetById([FromQuery(Name = "id")] int id) { Response oR = new Response(); try { var oSubCategory = await _service.GetById(id); if (oSubCategory == null) { oR.Status = StatusCodes.Status404NotFound; oR.Message = Messages.ResourceNotFound; return(NotFound(oR)); } oR.Status = StatusCodes.Status200OK; oR.Data = oSubCategory; return(Ok(oR)); } catch (Exception ex) { oR.Status = StatusCodes.Status500InternalServerError; oR.Message = Messages.InternalServerError; return(StatusCode(StatusCodes.Status500InternalServerError, oR)); } }
public async Task <IActionResult> GetById(Guid id) { try { return(Ok(await _subCategoryService.GetById(id))); } catch (Exception e) { _loggerManager.LogError($"Ocurrio un error al obtener el subcategory: {e}"); throw new ApiException(AppResources.BadRequest, HttpStatusCode.BadRequest); } }
public async Task <IActionResult> GetById(Guid id) { var subCategory = await _service.GetById(id); return(Ok(subCategory)); }