public IHttpActionResult Update(string id, AuthorPostRep resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } try { var @event = new AuthorUpdateEvent { Id = Guid.Parse(id), FirstName = resource.FirstName, LastName = resource.LastName, Country = resource.Country }; this._authorService.Update(@event); return(this.CreatedAtRoute(AuthorResourceNames.Routes.GetById, new { id = @event.Id }, new { })); } catch (FormatException) { return(this.BadRequest()); } catch (ObjectNotFoundException) { return(this.NotFound()); } catch (Exception ex) { return(this.InternalServerError(ex)); } }
public void Update(AuthorUpdateEvent @event) { var entity = this._authorEntityService.Get(@event.Id); if (entity == null) { throw new ObjectNotFoundException(); } entity = this.CreateOrUpdate(@event, entity); this._authorEntityService.Edit(entity); this._authorEntityService.Save(); }