Ejemplo n.º 1
0
        public IHttpActionResult Update(string id, CategoryPostRep resource)
        {
            if (!this.ModelState.IsValid)
            {
                return(this.BadRequest(this.ModelState));
            }

            try
            {
                var @event = new CategoryUpdateEvent
                {
                    Id          = Guid.Parse(id),
                    Name        = resource.Name,
                    Description = resource.Description
                };

                this._categoryService.Update(@event);

                return(this.CreatedAtRoute(CategoryResourceNames.Routes.GetById, new { id = @event.Id }, new { }));
            }
            catch (FormatException)
            {
                return(this.BadRequest());
            }
            catch (ObjectNotFoundException)
            {
                return(this.NotFound());
            }
            catch (Exception ex)
            {
                return(this.InternalServerError(ex));
            }
        }
Ejemplo n.º 2
0
        public void Update(CategoryUpdateEvent @event)
        {
            var entity = this._categoryEntityService.Get(@event.Id);

            if (entity == null)
            {
                throw new ObjectNotFoundException();
            }

            entity = this.CreateOrUpdate(@event, entity);

            this._categoryEntityService.Edit(entity);
            this._categoryEntityService.Save();
        }
Ejemplo n.º 3
0
 public Task Handle(CategoryUpdateEvent notification, CancellationToken cancellationToken)
 {
     _eventBus.AddEvent(notification);
     return(Task.CompletedTask);
 }
Ejemplo n.º 4
0
 public Task Handle(CategoryUpdateEvent notification, CancellationToken cancellationToken)
 {
     return(Task.CompletedTask);
 }