Beispiel #1
0
        public void AddOrder(CheckOutInputModel info, string id)
        {
            var cart  = _cartService.GetCart(id);
            var order = new Order
            {
                UserId         = id,
                DateOfPurchase = System.DateTime.Today
            };

            var orderid = _orderRepo.WriteOrder(order);

            foreach (var n in cart)
            {
                var bio = new BooksInOrder
                {
                    OrderId  = orderid,
                    Title    = n.Title,
                    Price    = n.Price,
                    Quantity = n.Quantity
                };
                _orderRepo.AddBookOrderConnection(bio);
            }
            var cardNumber = "xxxxxxxxxxxx";

            cardNumber += info.CardNumber.Substring(12);
            var orderInfo = new OrderInfo
            {
                OrderId                = orderid,
                UserId                 = id,
                ShippingFirstName      = info.ShippingFirstName,
                ShippingLastName       = info.ShippingLastName,
                ShippingStreetName     = info.ShippingStreetName,
                ShippingHouseNumber    = info.ShippingHouseNumber,
                ShippingCity           = info.ShippingCity,
                ShippingZipCode        = info.ShippingZipCode,
                ShippingCountry        = info.ShippingCountry,
                BillingFirstName       = info.BillingFirstName,
                BillingLastName        = info.BillingLastName,
                BillingStreetName      = info.BillingStreetName,
                BillingHouseNumber     = info.BillingHouseNumber,
                BillingCity            = info.BillingCity,
                BillingZipCode         = info.BillingZipCode,
                BillingCounry          = info.BillingCountry,
                PaymentFullName        = info.FullName,
                PaymentCardNumber      = cardNumber,
                PaymentExpirationMonth = info.ExpirationMonth,
                PaymentExpirationYear  = info.ExpirationYear,
            };

            _orderRepo.AddOrderInfo(orderInfo);
            _cartService.ClearCart(id);
        }