public IHttpActionResult Put(Guid id, [FromBody] CreateSpot spot) { if (id == default(Guid) || !ModelState.IsValid) { return(BadRequest(ModelState)); } var existingSpot = _repository.Find(id); if (existingSpot is null) { return(this.Error().ResourceNotFound("Spot not found")); } try { spot.Validate(); } catch (BreakTypeException ex) { ModelState.AddModelError( nameof(CreateSpot.BreakType), BreakTypeValueErrorMessage(ex) ); return(BadRequest(ModelState)); } existingSpot.Update(spot); _repository.Update(existingSpot); _repository.SaveChanges(); return(Ok(existingSpot)); }
public Spot Update(Spot spot) { return(_spotRepository.Update(spot)); }