Exemplo n.º 1
0
        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));
            }
        }
Exemplo n.º 2
0
        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;
        }