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