public async override Task <CommandExecutionResult> ExecuteAsync()
        {
            var totalAmount = OrderItems.Sum(item => item.Price * item.Quantity);

            var orderItems = OrderItems.Select(items => new OrderItem(items.ProductId,
                                                                      items.Quantity,
                                                                      items.Price * items.Quantity,
                                                                      PaymentMethod));

            var paymentDetails = new PaymentDetails(CashAmount,
                                                    CardNumber,
                                                    CardOwner,
                                                    totalAmount,
                                                    PaymentMethod);

            var paymentFactory = PaymentFactory.Create(paymentDetails);
            var paymentResult  = paymentFactory.Pay(paymentDetails);

            if (!paymentResult.IsSuccess)
            {
                return(await FailAsync(ErrorCode.PaymentUnsuccesfull));
            }

            var order = new Domain.OrderManagement.Order(BoothId,
                                                         totalAmount,
                                                         OrderStatus.Placed,
                                                         orderItems.ToList());

            await SaveAsync(order, _orderRepository);

            return(await OkAsync(DomainOperationResult.CreateEmpty()));
        }
Ejemplo n.º 2
0
        public override CommandExecutionResult Execute()
        {
            var @event = new Event(EventName, EventDate, new Venue(VenueName, Longitude, Latitude), SeatCount, Poster, VideoUrl, Description);

            _db.Set <Event>().Add(@event);

            _unitOfWork.Save();

            return(Ok(DomainOperationResult.CreateEmpty()));
        }
Ejemplo n.º 3
0
        public async override Task <CommandExecutionResult> ExecuteAsync()
        {
            var boothStaff = await _db.Set <BoothStaff>()
                             .FirstOrDefaultAsync(staff => staff.Id == Id);

            if (boothStaff == null)
            {
                return(await FailAsync(ErrorCode.NotFound));
            }

            _db.Set <BoothStaff>()
            .Remove(boothStaff);

            await _unitOfWork.SaveAsync();

            return(await OkAsync(DomainOperationResult.CreateEmpty()));
        }
Ejemplo n.º 4
0
        public async override Task <CommandExecutionResult> ExecuteAsync()
        {
            try
            {
                var product = await _productRepository.GetByIdAsync(Id);

                if (product == null)
                {
                    return(await FailAsync(ErrorCode.NotFound));
                }

                product.RaiseDeleteEvent();

                _productRepository.Delete(product);
                await _unitOfWork.SaveAsync();

                return(await OkAsync(DomainOperationResult.CreateEmpty()));
            }
            catch (Exception)
            {
                return(await FailAsync(ErrorCode.Exception));
            }
        }