public IHttpActionResult Create(AuthorPostRep resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } try { var @event = new AuthorCreateEvent { FirstName = resource.FirstName, LastName = resource.LastName, Country = resource.Country }; this._authorService.Add(@event); return(this.CreatedAtRoute(AuthorResourceNames.Routes.GetById, new { id = @event.Id }, resource)); } catch (Exception ex) { return(this.InternalServerError(ex)); } }
public void Add(AuthorCreateEvent @event) { var entity = new Author(); entity = this.CreateOrUpdate(@event, entity); entity.Id = Guid.NewGuid(); this._authorEntityService.Add(entity); this._authorEntityService.Save(); @event.Id = entity.Id; }