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)); } }
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(); }
public Task Handle(CategoryUpdateEvent notification, CancellationToken cancellationToken) { _eventBus.AddEvent(notification); return(Task.CompletedTask); }
public Task Handle(CategoryUpdateEvent notification, CancellationToken cancellationToken) { return(Task.CompletedTask); }