public IActionResult GetOneBeforeCellphone(string beforeCellphone) { try { CellphoneModel cellphoneModel = cellphoneRepository.GetOneBeforeCellphone(beforeCellphone); return(Ok(cellphoneModel)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(StatusCode(StatusCodes.Status500InternalServerError, errors)); } }
public IActionResult AddCellphone(CellphoneModel cellphoneModel) { try { if (cellphoneModel == null) { return(BadRequest("Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(BadRequest(errors)); } CellphoneModel addedCellphone = cellphoneRepository.AddCellphone(cellphoneModel); return(StatusCode(StatusCodes.Status201Created, addedCellphone)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(StatusCode(StatusCodes.Status500InternalServerError, errors)); } }
public IActionResult UpdateCellphone(string beforeCellphone, CellphoneModel cellphoneModel) { try { if (cellphoneModel == null) { return(BadRequest("Data is null.")); } if (!ModelState.IsValid) { Errors errors = ErrorsHelper.GetErrors(ModelState); return(BadRequest(errors)); } cellphoneModel.beforeCellphone = beforeCellphone; CellphoneModel updatedCellphone = cellphoneRepository.UpdateCellphone(cellphoneModel); return(Ok(updatedCellphone)); } catch (Exception ex) { Errors errors = ErrorsHelper.GetErrors(ex); return(StatusCode(StatusCodes.Status500InternalServerError, errors)); } }