public IActionResult setPointOfInterest(int cityId, [FromBody] PointOfInterestOfCreationDto pointOfInterest) { if (pointOfInterest == null) { return(BadRequest()); } if (pointOfInterest.Name.Equals(pointOfInterest.Description)) { ModelState.AddModelError("NameDesctiption", "the name and description can't be equal"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var existCity = _cityService.GetById(cityId); if (existCity == null) { return(NotFound()); } int createdId = _pointOfInterestservice.Create(new PointOfInterestDto() { Name = pointOfInterest.Name, Description = pointOfInterest.Description, CityId = cityId }); return(CreatedAtRoute("getPointOfInterestById", new { cityId = cityId, id = createdId }, pointOfInterest)); }
public IActionResult updatePointOfInterest(int cityId, int id, [FromBody] PointOfInterestOfCreationDto pointOfInterest) { if (pointOfInterest == null) { return(BadRequest()); } if (pointOfInterest.Name.Equals(pointOfInterest.Description)) { ModelState.AddModelError("NameDesctiption", "the name and description can't be equal"); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var existCity = _cityService.GetById(cityId, true); if (existCity == null) { return(NotFound()); } var existPointOfInterest = _pointOfInterestservice.GetById(id, true); if (existPointOfInterest == null) { return(NotFound()); } var updatePoint = new PointOfInterestDto() { Id = existPointOfInterest.Id, CityId = cityId, Name = pointOfInterest.Name, Description = pointOfInterest.Description }; _pointOfInterestservice.Update(updatePoint); return(NoContent()); }