Ejemplo n.º 1
0
        public IActionResult PlaceOrder()
        {
            ISession      session = HttpContext.Session;
            CartViewModel cart    = this._sessionCartStorage.GetCartFromSession(session);
            Order         order   = new Order();

            order.Id = Guid.NewGuid();
            order.OrderDateCreated = new DateTime();
            order.Bouquets         = cart.items;
            _orderStorage.AddOrder(order);

            OrderViewModel viewModel = new OrderViewModel();

            viewModel.orderNumber = order.Id.ToString();
            _sessionCartStorage.RemoveCartFromSession(session);
            return(View("Index", viewModel));
        }
Ejemplo n.º 2
0
        public async ValueTask <RequestResult <Order> > AddOrder(Order model)
        {
            var      result = new RequestResult <Order>();
            DateTime today  = DateTime.Today;

            try
            {
                if (CurrencyRates.ActualCurrencyRates == null || CurrencyRates.ActualCurrencyRates.Find(i => Equals(i.Date, today)).Date == null)
                {
                    string path = "";
                    switch (model.Warehouse.Id)
                    {
                    case (int)WarehouseEnum.Minsk:
                        path = "BYN";
                        _sendRequest.GetLocalCurrency(path);
                        break;

                    case (int)WarehouseEnum.Kiev:
                        path = "UAH";
                        _sendRequest.GetLocalCurrency(path);
                        break;

                    default: break;
                    }
                }


                foreach (OrderDetails item in model.OrderDetails)
                {
                    item.LocalPrice /= CurrencyRates.ActualCurrencyRates.Find(i => Equals(i.Date, today)).Rate;
                }
                _orderStorage.TransactionStart();
                result.RequestData = await _orderStorage.AddOrder(model);

                _orderStorage.TransactionCommit();
                result.IsOk = true;
            }
            catch (Exception ex)
            {
                _orderStorage.TransactionRollBack();
                result.ExMessage = ex.Message;
            }
            return(result);
        }
Ejemplo n.º 3
0
        public async ValueTask <RequestResult <Order> > AddOrder(Order dataModel)
        {
            var result = new RequestResult <Order>();

            try
            {
                string  path;
                decimal curCurrency = 1;
                switch (dataModel.City.Id)
                {
                case (int?)CityEnum.Kiev:
                    path        = "UAH";
                    curCurrency = await CurrentCurrency.GetCurrency(path);

                    break;

                case (int?)CityEnum.Minsk:
                    path        = "BYN";
                    curCurrency = await CurrentCurrency.GetCurrency(path);

                    break;
                }
                foreach (var item in dataModel.OrderDetails)
                {
                    item.LocalPrice /= curCurrency;
                }
                _orderStorage.TransactionStart();
                result.RequestData = await _orderStorage.AddOrder(dataModel);

                _orderStorage.TransactionCommit();
                result.IsOkay = true;
            }
            catch (Exception ex)
            {
                _orderStorage.TransactioRollBack();
                result.ExMessage = ex.Message;
            }
            return(result);
        }
        public async ValueTask <RequestResult <Order> > AddOrder(Order dataModel)
        {
            if (!Russia.Cities.Contains(dataModel.FilialCity))
            {
                await ConvertPrices(dataModel);
            }
            var result = new RequestResult <Order>();

            try
            {
                _orderStorage.TransactionStart();
                result.RequestData = await _orderStorage.AddOrder(dataModel);

                _orderStorage.TransactionCommit();
                result.IsOkay = true;
            }
            catch (Exception ex)
            {
                _orderStorage.TransactioRollBack();
                result.ExMessage = ex.Message;
            }
            return(result);
        }