public int DeleteOrder(int orderId) { Order order = _dbContext.Orders.FirstOrDefault(x => x.Id == orderId); ReleasedProductsDataEvent releasedProductsDataEvent = new ReleasedProductsDataEvent() { ProductsDetails = _converter.CommandToEvent(order.OrdersData) }; _eventEmitter.EmitReleasedProductsDataEvent(releasedProductsDataEvent); _dbContext.Orders.Remove(order); SaveChanges(); return((int)DeleteOrderStatusCode.DeletedSuccessfuly); }
public ActionResult PostLocationReport(Guid memberId, [FromBody] LocationReport locationReport) { MemberLocationRecordedEvent locationRecordedEvent = converter.CommandToEvent(locationReport); locationRecordedEvent.TeamID = teamServiceClient.GetTeamForMember(locationReport.MemberID); eventEmitter.EmitLocationRecordedEvent(locationRecordedEvent); return(this.Created($"/api/members/{memberId}/locationreports/{locationReport.ReportID}", locationReport)); }
public async Task <IActionResult> Post(Guid memberId, [FromBody] LocationReport locationReport) { var locationRecordedEvent = _commandEventConverter.CommandToEvent(locationReport); locationRecordedEvent.TeamId = await _teamServiceClient.GetTeamForMemberAsync(locationReport.MemberId); _eventEmitter.EmitLocationRecordedEvent(locationRecordedEvent); return(this.Created($"/api/members/{memberId}/locationreposts/{locationReport.Id}", locationReport)); }
public ActionResult Add([FromBody] Product product) { var id = this.productRepository.Add(product); NewProductEvent newProductEvent = converter.CommandToEvent(product); eventEmitter.EmitProductAddedEvent(newProductEvent); return(Ok(id)); }
public async Task <CommandResult> Handle(CreateUpdateConceptosCommand request, CancellationToken cancellationToken) { //Business Logic Here try { int Id = await CreateConcepto(request.Concepto, cancellationToken); Log.Information("Concepto creado {@concepto}", request.Concepto); _eventEmitter.EmitConceptoCreatedEvent(_converter.CommandToEvent(request)); request.Concepto.Id = Id; return(CommandResult.Success(request.Concepto)); } catch (Exception ex) { return(CommandResult.Fail(ex.Message)); } }