public void Put(Guid id, [FromBody] UpdatePointOfInterest pof) { var entity = _repository.GetById(id); entity.Update(pof.Description, pof.Location, pof.Name); // magic _repository.Edit(entity); }
public IActionResult CreatePointofInterest(int cityId, int id, [FromBody] UpdatePointOfInterest pointOfInterest) { try { if (pointOfInterest.Description == pointOfInterest.Name) { ModelState.AddModelError( "Description", "The Name and description should not be the same" ); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!_cityInfoRepository.IsExist(id)) { _ilogger.LogInformation($"The id : {id} does not exist"); return(NotFound()); } var gettingtheID = _cityInfoRepository.GetPointOfInterest(cityId, id); if (gettingtheID == null) { return(NotFound()); } _mapper.Map(pointOfInterest, gettingtheID); _cityInfoRepository .Updatepointofinterest(cityId, gettingtheID); return(NoContent()); } catch (Exception e) { _ilogger.LogCritical($"Exception while getting id with {cityId}", e); return(StatusCode(500, "A problem happened while loading request")); } }