public ActionResult UpdateBrand(int id = 0)
        {
            BrandBO model = new BrandBO();

            if (id > 0)
            {
                model = BrandModel.GetBrandByID(id);
            }
            return(View(model));
        }
Beispiel #2
0
        public ActionResult Index(string metatitle, int id, int attribute_pa_chon_chat_lieu_op_lung = 0, string cart_item_key = "")
        {
            if (metatitle.Length <= 0 || metatitle.Split('-').Count() <= 1)
            {
                return(RedirectToAction("NotFound", "Error"));
            }


            var product = ProductDAO.GetProductByID(id);

            if (product == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            product.avatar.OrderBy(x => x.displayorder);
            product.slide.OrderBy(x => x.displayorder);

            if (product.collectionid > 0)
            {
                ViewBag.CollectionName = BrandModel.GetCollectionByID(Convert.ToInt32(product.collectionid)).name;
            }
            else
            {
                ViewBag.BrandName = BrandModel.GetBrandByID(Convert.ToInt32(product.brandid)).name;
            }

            ViewBag.CurrentMaterialID = attribute_pa_chon_chat_lieu_op_lung;
            CartSession cart = new CartSession();

            if (!String.IsNullOrEmpty(cart_item_key))
            {
                List <CartSession> lstCartItem = Session["fancycart"] as List <CartSession>;
                if (lstCartItem != null)
                {
                    cart = lstCartItem.Where(x => x.ItemKey == cart_item_key).FirstOrDefault();
                }
            }
            if (cart == null)
            {
                cart = new CartSession();
            }
            if (!String.IsNullOrEmpty(cart.Order))
            {
                cart.OrderObject            = JsonConvert.DeserializeObject <dynamic>(cart.Order);
                cart.OrderObject_Additional = cart.OrderObject.product[0];
            }

            ViewBag.CurrentCartItem = cart;
            var commonInfo = LocationDAO.GetCommonInfoByID("commoninfo");

            ViewBag.CommonInfo = commonInfo;
            return(View(product));
        }
        public ActionResult UpdateBrand(BrandBO brandModel)
        {
            if (ModelState.IsValid)
            {
                UserLogin user         = (UserLogin)Session[CommonConstants.USER_SESSION];
                string    errorMessage = "";
                bool      result       = false;
                brandModel.isdeleted = 0;
                if (brandModel.id > 0)
                {
                    //get updatemodel
                    BrandBO newUpdateBO = new BrandBO();
                    newUpdateBO = BrandModel.GetBrandByID(brandModel.id);
                    if (newUpdateBO == null)
                    {
                        ModelState.AddModelError("", "Brand không tồn tại");
                        return(View(brandModel));
                    }

                    newUpdateBO.updateduser     = user.UserID.ToString();
                    newUpdateBO.updateddate     = DateTime.Now;
                    newUpdateBO.description     = brandModel.description;
                    newUpdateBO.isdeleted       = 0;
                    newUpdateBO.keyword         = brandModel.keyword;
                    newUpdateBO.logo            = brandModel.logo;
                    newUpdateBO.metadescription = brandModel.metadescription;
                    newUpdateBO.metakeyword     = brandModel.metakeyword;
                    newUpdateBO.name            = brandModel.name;
                    newUpdateBO.seoname         = brandModel.seoname;

                    result = BrandModel.UpdateBrand(newUpdateBO, ref errorMessage);
                    SetAlert($"Cập nhật Brand {brandModel.id}-{brandModel.name} thành công", "success");
                }
                else
                {
                    brandModel.createduser = user.UserID.ToString();
                    brandModel.createddate = DateTime.Now;
                    result = BrandModel.InsertBrand(brandModel, ref errorMessage);
                    SetAlert($"Thêm Brand {brandModel.name} thành công", "success");
                }

                if (result)
                {
                    return(RedirectToAction("Brand", "Category"));
                }
                else
                {
                    ModelState.AddModelError("", "Có lỗi xảy ra. Thêm thất bại: " + errorMessage);
                }
            }

            return(View(brandModel));
        }
        public ActionResult Index(string metatitle, int id, string orderby = "")
        {
            if (metatitle.Length <= 0 && metatitle.Split('-').Count() < 2)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            var brandInfo = BrandModel.GetBrandByID(id);

            if (brandInfo == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            ViewBag.OrderBy = orderby;
            return(View(brandInfo));
        }
Beispiel #5
0
        public ActionResult RelativeProduct(ProductBO objProductBO)
        {
            var listRelativeProduct = ProductDAO.GetListRelativeProduct(objProductBO.id, Convert.ToInt32(objProductBO.brandid), Convert.ToInt32(objProductBO.collectionid));

            if (objProductBO.collectionid > 0)
            {
                ViewBag.CollectionName = BrandModel.GetCollectionByID(Convert.ToInt32(objProductBO.collectionid)).name;
                ViewBag.CollectionID   = objProductBO.collectionid;
            }
            else
            {
                ViewBag.BrandName = BrandModel.GetBrandByID(Convert.ToInt32(objProductBO.brandid)).name;
                ViewBag.BrandID   = objProductBO.brandid;
            }

            return(PartialView(listRelativeProduct));
        }