Пример #1
0
        private ShipToAddressModel GetCustomerShipToAddress(int CustAutoID)
        {
            ShipToAddressModel CustomerAddressBaseModel = new ShipToAddressModel();

            CustomerShipToAddress customerShipToAddress = _context.CustomerShipToAddress.GetSingle(e => e.CustAutoID == CustAutoID);

            if (customerShipToAddress != null)
            {
                CustomerAddressBaseModel.ShipToAddress = new AddressBaseModel();
                CustomerAddressBaseModel.ShipToAddress.AddressLine1 = customerShipToAddress.ShipToAddress1 != null ? customerShipToAddress.ShipToAddress1 : customerShipToAddress.ShipToAddress2;
                CustomerAddressBaseModel.ShipToName                = customerShipToAddress.ShipToName;
                CustomerAddressBaseModel.ShipToAddress.City        = customerShipToAddress.ShipToCity;
                CustomerAddressBaseModel.ShipToAddress.State       = customerShipToAddress.ShipToState;
                CustomerAddressBaseModel.ShipToAddress.ZipCode     = customerShipToAddress.ShipToZipCode;
                CustomerAddressBaseModel.ShipToAddress.CountryCode = customerShipToAddress.ShipToCountryCode;
            }
            return(CustomerAddressBaseModel);
        }
Пример #2
0
        public ShoppingCartViewModel GetShoppingCartView(int quoteid)
        {
            ShoppingCartViewModel scVM = new ShoppingCartViewModel();
            Quote quote = _Context.Quote.GetSingle(e => e.QuoteID == quoteid);

            if (quote != null)
            {
                scVM.QuoteID = quoteid;
                scVM.IncludeCatalogStatus = (bool)quote.IncludeCatalogStatus;
                scVM.QuoteTypeID          = (int)quote.QuoteTypeID;
                scVM.CustUserID           = quote.UserID;


                scVM.CartListView = quote.QuoteDetails.Select(c => new CartViewModel
                {
                    Title         = c.Item.Title,
                    Author        = c.Item.Author == null ? "" : c.Item.Author.AuthorName,
                    ISBN          = c.Item.ISBN,
                    AR            = c.Item.ARLevel,
                    Lexile        = c.Item.Lexile,
                    ItemPrice     = (double)c.Item.Price,
                    ItemId        = c.Item.ItemID,
                    Quantity      = c.Quantity,
                    ProductLine   = c.Item.ProductLine,
                    RC            = c.Item.RCLevel,
                    Series        = c.Item.SeriesAndCharacter1 == null ? "" : c.Item.SeriesAndCharacter1.SCText,
                    QuoteDetailID = c.QuoteDetailID,
                    Type          = string.Empty,
                    LevelType     = string.Empty,
                    ItemStatus    = c.Item.Status
                }).OrderBy(e => e.Title).ToList();

                List <FlatFileDetailModel> lstCatalogInfo = GetCatalogInfoData(UserVM.CRMModelProperties.CustAutoID, quoteid, "Cart");

                scVM.CartListView.AddRange(lstCatalogInfo.Select(c => new CartViewModel
                {
                    Title          = c.ItemNumber,
                    Author         = string.Empty,
                    ISBN           = string.Empty,
                    AR             = null,
                    Lexile         = string.Empty,
                    ItemId         = c.ItemCode,
                    Quantity       = c.Quantity,
                    ItemPrice      = c.ItemPrice,
                    Price          = c.Price,
                    ProductLine    = c.ProductLine,
                    IncludeCatalog = c.ItemNumber == "Special Bulk Charge" ? false : true,
                    Type           = "Catalog",
                    LevelType      = c.LevelType,
                }).ToList());
                string taxschuduleID = quote.User.Customer != null ? quote.User.Customer.TaxScheduleID : null;
                scVM.CustomerName = quote.User != null ? quote.User.Customer != null ? quote.User.Customer.CustomerName : string.Empty : string.Empty;
                if (string.IsNullOrEmpty(taxschuduleID) || taxschuduleID == "NONTAX")
                {
                    scVM.SalesTax = 0;
                }
                else
                {
                    scVM.SalesTax = Convert.ToDecimal(_Context.TaxSchedule.GetSingle(e => e.TaxScheduleID == taxschuduleID).TaxRate);
                }
            }
            scVM.UserVM = UserVM;
            //scVM.UserVM.CRMModelProperties.LoggedINCustomerUserID = quote.UserID;
            scVM.UserVM.SCCount = quote.QuoteDetails.Sum(e => e.Quantity);
            scVM.UserVM.SCPrice = quote.QuoteDetails.Sum(e => e.Quantity * e.Item.Price);
            CustomerShipToAddress customerShipToAddress = _Context.CustomerShipToAddress.GetSingle(e => e.CustAutoID == UserVM.CRMModelProperties.CustAutoID);

            if (customerShipToAddress != null)
            {
                scVM.ShippingAddress = customerShipToAddress.ShipToAddress1 != null ? customerShipToAddress.ShipToAddress1 : customerShipToAddress.ShipToAddress2;
                scVM.ShipTo          = customerShipToAddress.ShipToName;
                scVM.ShipToCity      = customerShipToAddress.ShipToCity;
                scVM.State           = customerShipToAddress.ShipToState;
                scVM.ZipCode         = customerShipToAddress.ShipToZipCode;
                scVM.Country         = customerShipToAddress.ShipToCountryCode;
            }

            return(scVM);
        }