public async Task <IActionResult> LeaveCommentAsync([FromBody] CommentDetailsViewModel model) { try { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(StatusCode(StatusCodes.Status422UnprocessableEntity)); } var endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleWriteServiceQueue); await endPoint.Send <IInsertCommentCommand>(new { model.AddedBy, model.AddedByEmail, model.ArticleId, model.CategoryId, model.Body }); return(Accepted()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IActionResult> InsertCategoryAsync(AddCategoryViewModel model) { try { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(StatusCode(StatusCodes.Status422UnprocessableEntity)); } var endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleWriteServiceQueue); await endPoint.Send <IInsertCategoryCommand>(new { model.Description, model.ImageUrl, model.Importance, model.Title }); return(Accepted()); } catch (Exception ex) { return(InternalServerError(ex)); } }
public async Task <IActionResult> UpdateArticleAsync(Guid articleId, [FromBody] EditArticleViewModel model) { try { if (model == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(StatusCode(StatusCodes.Status422UnprocessableEntity)); } var endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleWriteServiceQueue); await endPoint.Send <IUpdateArticleCommand>(new { model.Id, model.Body }); return(Accepted()); } catch (Exception ex) { return(InternalServerError(ex)); } }
private async Task SendEventAsync(Article article) { ISendEndpoint endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleSagaQueue); foreach (IEvent @event in article.GetUncommittedEvents()) { var obj = (ISagaArticleUpdatedEvent)@event; await endPoint.Send <ISagaArticleUpdatedEvent>(new { obj.AggregateId, obj.Abstract, obj.Approved, obj.Body, obj.CategoryId, obj.City, obj.CommentsEnabled, obj.Country, obj.ExpireDate, obj.Listed, obj.OnlyForMembers, obj.ReleaseDate, obj.State, obj.Title }); } }
public async Task SendEvent(IEvent @event) { ISendEndpoint endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleSagaQueue); var obj = (ISagaCategoryInsertedEvent)@event; await endPoint.Send <ISagaCategoryInsertedEvent>(new { obj.AggregateId, obj.AddedBy, obj.AddedDate, }); }
private async Task SendEventAsync(Article article) { ISendEndpoint endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleSagaQueue); foreach (IEvent @event in article.GetUncommittedEvents()) { var obj = (ISagaArticleViewCountIncrementedEvent)@event; await endPoint.Send <ISagaArticleViewCountIncrementedEvent>(new { obj.AggregateId }); } }
private async Task SendEventAsync(Category category) { ISendEndpoint endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleSagaQueue); foreach (IEvent @event in category.GetUncommittedEvents()) { var obj = (ISagaCategoryDeletedEvent)@event; await endPoint.Send <ISagaCategoryDeletedEvent>(new { obj.AggregateId }); } }
private async Task SendEventAsync(Category category) { ISendEndpoint endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleSagaQueue); foreach (IEvent @event in category.GetUncommittedEvents()) { var obj = (ISagaCategoryUpdatedEvent)@event; await endPoint.Send <ISagaCategoryUpdatedEvent>(new { obj.AggregateId, obj.Description, obj.ImageUrl, obj.Importance, obj.Title }); } }
public async Task <IActionResult> DeleteArticleAsync(Guid articleId) { try { var endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleWriteServiceQueue); await endPoint.Send <IDeleteArticleCommand>(new { Id = articleId }); return(Accepted()); } catch (Exception ex) { return(InternalServerError(ex)); } }
private async Task SendEventAsync(Article article) { ISendEndpoint endPoint = await BusConfigurator.GetEndPointAsync(RabbitMqConstants.ArticleSagaQueue); foreach (IEvent @event in article.GetUncommittedEvents()) { var obj = (ISagaCommentInsertedEvent)@event; await endPoint.Send <ISagaCommentInsertedEvent>(new { obj.AggregateId, obj.AddedBy, obj.AddedByEmail, obj.AddedByIp, obj.AddedDate, obj.ArticleId, obj.Body }); } }