public ProductPageModel GetProductPageDataOffline(int product_id)
        {
            ProductPageModel prdModel = new ProductPageModel();

            using (var ctx = new RachnaDBContext())
            {
                CartModel _cartMdl = new CartModel();
                prdModel.Carts   = _cartMdl.GetCarts();
                prdModel.Product = bProduct.List().Where(m => m.Product_Id == product_id).FirstOrDefault();
                prdModel.Product.ProductBanner = bProduct.ListProductBanner().Where(m => m.Product_Id == prdModel.Product.Product_Id).ToList();
                prdModel.Product.SubCategory   = bSubCategory.List().Where(m => m.SubCategory_Id == prdModel.Product.SubCategory_Id).FirstOrDefault();

                prdModel.RelatedProducts = bProduct.List().Where(m => m.Product_Id != prdModel.Product.Product_Id).Take(4).ToList();
                foreach (var item in prdModel.RelatedProducts)
                {
                    item.ProductBanner = bProduct.ListProductBanner().Where(m => m.Product_Id == item.Product_Id).ToList();
                }

                prdModel.ProductFeatures = ctx.ProductFeature.Where(m => m.Product_Feature_Type == eProductFeature.Best.ToString()).ToList();
                foreach (var item in prdModel.ProductFeatures)
                {
                    item.Product = bProduct.List().Where(m => m.Product_Id == item.Product_Id).FirstOrDefault();
                    item.Product.ProductBanner = bProduct.ListProductBanner().Where(m => m.Product_Id == item.Product_Id).ToList();
                }

                prdModel.ProductFeatures2 = ctx.ProductFeature.Where(m => m.Product_Feature_Type == eProductFeature.OurChoice.ToString()).ToList();
                foreach (var item in prdModel.ProductFeatures2)
                {
                    item.Product = bProduct.List().Where(m => m.Product_Id == item.Product_Id).FirstOrDefault();
                    item.Product.ProductBanner = bProduct.ListProductBanner().Where(m => m.Product_Id == item.Product_Id).ToList();
                }

                prdModel.Categories = bCategory.List().Where(m => m.Category_Status == eStatus.Active.ToString()).ToList();
                foreach (var item in prdModel.Categories)
                {
                    item.SubCategory = bSubCategory.List().Where(m => m.Category_Id == item.Category_Id && item.Category_Status == eStatus.Active.ToString()).ToList();
                }

                prdModel.ProdComments = ctx.ProdComments.Where(m => m.Product_Id == prdModel.Product.Product_Id).ToList();
                if (HttpContext.Current.Session["UserKey"] != null)
                {
                    int CustomerId = Convert.ToInt32(HttpContext.Current.Session["UserKey"].ToString());
                    List <ProdComments> _commentsTemp = new List <ProdComments>();
                    _commentsTemp = ctx.ProdComments.Where(m => m.Customer_Id == CustomerId).ToList();
                    if (_commentsTemp != null)
                    {
                        prdModel.AlreadyCommentsDone = 1;
                        prdModel.ProdComments.AddRange(_commentsTemp);
                    }
                }
                return(prdModel);
            }
        }
Exemplo n.º 2
0
        public HeaderModel Get()
        {
            HeaderModel _header   = new HeaderModel();
            CartModel   CartModel = new CartModel();

            using (var context = new RachnaDBContext())
            {
                _header._logo  = context.Logo.Where(m => m.Logo_Status == eStatus.Active.ToString()).FirstOrDefault();
                _header._carts = CartModel.GetCarts();
                _header._menu  = context.RMenu.ToList();
                if (HttpContext.Current.Session["UserKey"] != null)
                {
                    int cusId = Convert.ToInt32(HttpContext.Current.Session["UserKey"].ToString());
                    _header._customer = context.Customer.ToList().Where(m => m.Customer_Id == cusId).FirstOrDefault();
                }
                _header._contact = context.ContactOwner.Where(m => m.Contact_Status == eStatus.Active.ToString()).FirstOrDefault();
            }
            return(_header);
        }