public void Add(CategoryCreateEvent @event) { var entity = new Category(); entity = this.CreateOrUpdate(@event, entity); entity.Id = Guid.NewGuid(); this._categoryEntityService.Add(entity); this._categoryEntityService.Save(); @event.Id = entity.Id; }
public IHttpActionResult Create(CategoryPostRep resource) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } try { var @event = new CategoryCreateEvent { Name = resource.Name, Description = resource.Description }; this._categoryService.Add(@event); return(this.CreatedAtRoute(CategoryResourceNames.Routes.GetById, new { id = @event.Id }, resource)); } catch (Exception ex) { return(this.InternalServerError(ex)); } }