Beispiel #1
0
        public void AddToCart(CurrentProductDTO prod, int UserID)
        {
            ModelAW          db   = new ModelAW();
            ShoppingCartItem cart = new ShoppingCartItem()
            {
                ProductID      = prod.ProductID,
                ShoppingCartID = UserID.ToString(),
                ModifiedDate   = DateTime.Now,
                DateCreated    = DateTime.Now,
                Quantity       = prod.Count
            };

            db.ShoppingCartItems.Add(cart);
            db.SaveChanges();
        }
Beispiel #2
0
        public CurrentProductDTO Get(int id)
        {
            IEnumerable <CurrentProductDTO> product = from ProductProductPhoto PPI in db.ProductProductPhotoes
                                                      join Product Prod in db.Products on PPI.ProductID equals Prod.ProductID
                                                      join ProductPhoto Photo in db.ProductPhotoes on PPI.ProductPhotoID equals Photo.ProductPhotoID
                                                      where Prod.ProductID == id
                                                      select new CurrentProductDTO
            {
                ProductID     = Prod.ProductID,
                ProductName   = Prod.Name,
                LargePhoto    = Photo.LargePhoto,
                ModelID       = Prod.ProductModelID,
                Class         = Prod.Class,
                Size          = Prod.Size,
                Color         = Prod.Color,
                ProductNumber = Prod.ProductNumber,
                SizeUnit      = Prod.SizeUnitMeasureCode,
                ProductLine   = Prod.ProductLine,
                Weight        = Prod.Weight,
                Style         = Prod.Style
            };
            CurrentProductDTO fullInfo = product.FirstOrDefault();

            if (fullInfo.ModelID != null)
            {
                IEnumerable <CurrentProductDTO> Model = from ProductModelProductDescriptionCulture info in db.ProductModelProductDescriptionCultures
                                                        join ProductModel model in db.ProductModels on info.ProductModelID equals model.ProductModelID
                                                        join ProductDescription desk in db.ProductDescriptions on info.ProductDescriptionID equals desk.ProductDescriptionID
                                                        where model.ProductModelID == fullInfo.ModelID && info.CultureID == "en"
                                                        select new CurrentProductDTO
                {
                    Model       = model.Name,
                    Description = desk.Description
                };
                fullInfo.Model       = Model.Select(m => m.Model).FirstOrDefault();
                fullInfo.Description = Model.Select(m => m.Description).FirstOrDefault();
            }
            fullInfo.InventoryQ = db.ProductInventories.Where(m => m.ProductID == fullInfo.ProductID).Sum(m => m.Quantity);
            return(fullInfo);
        }