Esempio n. 1
0
        public ActionResult Index()
        {
            var viewModel = new CartListViewModel();
            var list      = GetShoppingCart();
            //viewModel.Products = GetSopiingCart();

            var pricmodel      = _productSevice.GetAttribute("Price");
            var Guaranteemodel = _productSevice.GetAttribute("Guarantee");

            viewModel.Count    = list.Count;
            viewModel.Products = new List <CartItemViewModel>();
            foreach (DictionaryEntry it in list)
            {
                CartItemViewModel item = (CartItemViewModel)it.Value;

                var pr = _productSevice.Get(item.Id);
                if (pr != null)
                {
                    viewModel.Products.Add(item);

                    item.Image = pr.Image;
                    item.link  = AppHelpers.ProductUrls(pr.Category_Id, pr.Slug);

                    var Guarante = _productSevice.GetAttributeValue(item.Id, Guaranteemodel.Id);
                    if (Guarante != null)
                    {
                        item.Guarantee = Guarante.Value;
                    }

                    var price = _productSevice.GetAttributeValue(item.Id, pricmodel.Id);
                    if (price != null)
                    {
                        try
                        {
                            int p = int.Parse(price.Value);
                            item.Priceint         = p;
                            item.Price            = p.ToString("N0").Replace(",", ".") + " VND";
                            viewModel.TotalMoney += p * item.Count;
                        }
                        catch
                        {
                            item.Price = "Liên hệ";
                        }
                    }
                    else
                    {
                        item.Price = "Liên hệ";
                    }
                }
            }

            return(View(viewModel));
        }
Esempio n. 2
0
        public ActionResult EditProduct(Guid id)
        {
            var product = _productSevice.Get(id);

            if (product == null)
            {
                return(RedirectToAction("index"));
            }

            var cats = _categoryService.GetAllowedEditCategories(UsersRole, true);

            var model = new AdminEditProductViewModel
            {
                ProductClass = product.ProductClassId,
                Id           = product.Id,
                Category     = product.Category_Id,
                Image        = product.Image,
                IsLocked     = product.IsLocked,
                Name         = product.Name,
                Categories   = _categoryService.GetBaseSelectListCategories(cats),
                AllAttribute = new List <AdminAttributeViewModel>()
            };


            ProductPost post;

            if (product.ProductPost_Id != null)
            {
                post          = _productPostSevice.Get((Guid)product.ProductPost_Id);
                model.Content = post.PostContent;
            }

            var attr = _productSevice.GetListProductClassAttributeForProductClassId(product.ProductClassId);

            foreach (var it in attr)
            {
                var a = _productSevice.GetAttribute(it.ProductAttributeId);

                var m = new AdminAttributeViewModel
                {
                    AttriId   = a.Id,
                    Name      = a.LangName,
                    ValueType = a.ValueType,
                    IsNull    = a.IsNull
                };

                var p = _productSevice.GetAttributeValue(product.Id, a.Id);
                if (p != null)
                {
                    m.Id    = p.Id;
                    m.Value = p.Value;
                }

                if (!a.ValueOption.IsNullEmpty() && a.ValueType == 2)
                {
                    dynamic json = JsonConvert.DeserializeObject(a.ValueOption);
                    if (json != null)
                    {
                        m.ValueOptions = new List <string>();
                        foreach (var itt in json)
                        {
                            m.ValueOptions.Add((string)itt);
                        }
                    }
                }

                //if (!a.ValueFindter.IsNullEmpty())
                //{
                //	dynamic json = JsonConvert.DeserializeObject(a.ValueFindter);
                //	if (json != null)
                //	{
                //		m.FindterNums = new List<AdminAttributeNumberFindter>();
                //		foreach (dynamic itt in json)
                //		{
                //			m.FindterNums.Add(new AdminAttributeNumberFindter { Name = (string)itt.Name });
                //		}
                //	}
                //}

                model.AllAttribute.Add(m);
            }

            return(View(model));
        }
Esempio n. 3
0
        private AdminMenuEditViewModel CreateEditMenuViewModel(Menu menu)
        {
            var viewModel = new AdminMenuEditViewModel
            {
                Id          = menu.Id,
                ParentMenu  = menu.Menu_Id,
                Name        = menu.Name,
                Description = menu.Description,
                Colour      = menu.Colour,
                iType       = menu.iType,
                Image       = menu.Image,
                SortOrder   = menu.SortOrder,
                AllMenus    = _menuService.GetBaseSelectListMenus(_menuService.GetMenusParenMenu(menu)),
                AllType     = GetTypeLink(),
                AllPage     = GetPageLink(),
                //AllCat = _categoryService.GetBaseSelectListCategories(_categoryService.GetAll()),
                AllCatNews    = _categoryService.GetBaseSelectListCategories(_categoryService.GetList(false)),
                AllCatProduct = _categoryService.GetBaseSelectListCategories(_categoryService.GetList(true)),
            };

            switch (menu.iType)
            {
            case 0:
                viewModel.Link = menu.Link;
                break;

            case 1:
                viewModel.LinkPage = menu.Link;
                break;

            //case 2:
            //    viewModel.LinkCat = menu.Link;
            //    break;
            case 6:
                viewModel.LinkCatNews = menu.Link;
                break;

            case 7:
                viewModel.LinkCatProduct = menu.Link;
                break;

            case 3:
                if (!menu.Link.IsNullEmpty())
                {
                    var a = _topicService.Get(new Guid(menu.Link));
                    if (a != null)
                    {
                        viewModel.LinkNews  = menu.Link;
                        viewModel.TitleNews = a.Name;
                    }
                }
                break;

            case 4:
                if (!menu.Link.IsNullEmpty())
                {
                    var b = _productSevice.Get(new Guid(menu.Link));
                    if (b != null)
                    {
                        viewModel.LinkProduct  = menu.Link;
                        viewModel.TitleProduct = b.Name;
                    }
                }

                break;

            case 5:
                if (!menu.Link.IsNullEmpty())
                {
                    var b = _productSevice.GetProductClass(new Guid(menu.Link));
                    if (b != null)
                    {
                        viewModel.LinkGroupProduct  = menu.Link;
                        viewModel.TitleGroupProduct = b.Name;
                    }
                }
                break;
            }

            return(viewModel);
        }