public IActionResult Put([FromBody] TblCityModel TblCityModel) { try { var tblCity = _unitOfWork.tblCity.GetAll(); return(Ok(tblCity)); } catch (Exception ex) { Utilities.QuickLog($"Failed to TblCityController, Function : Put() : {ex}"); return(Ok(ex)); } }
public IActionResult UpdateSizes(Guid id, [FromBody] TblCityModel TblCityModel) { if (ModelState.IsValid) { if (TblCityModel == null) { return(BadRequest($"{nameof(TblCityModel)} cannot be null")); } if (id != TblCityModel.ID) { return(BadRequest("Conflicting Sizes id in parameter and model data")); } tblCity TblCity = _unitOfWork.tblCity.GetById(id); if (TblCity.Name != TblCityModel.Name) { var Exist = _unitOfWork.tblCity.GetAll().Where(x => x.Name == TblCityModel.Name).FirstOrDefault(); if (Exist != null) { var response1 = new { Success = false, Message = "tblCity Name already Exist.", }; return(Ok(response1)); } } if (TblCity == null) { return(NotFound(id)); } _imapper.Map <TblCityModel, tblCity>(TblCityModel, TblCity); try { _unitOfWork.tblCity.Update(TblCity); return(Ok()); } catch (Exception ex) { Utilities.QuickLog($"Failed to TblCityController, Function :Put() : {ex}"); return(BadRequest("Error Occurred")); } } return(BadRequest(ModelState)); }