예제 #1
0
 public ActionResult CreateParameter(ParametersModel param)
 {
     if (ModelState.IsValid)
     {
         ParametersRepository.Add(param.ProductId, param.Name, param.Value);
         return RedirectToAction("EditProduct", new { id = param.ProductId });
     }
     return View(param);
 }
예제 #2
0
        //
        // GET: /Admin/DetailsProduct/5
        public ActionResult DetailsProduct(int id)
        {
            Product product = repositoryProduct.Find(id);
            List<Parameter> param = ParametersRepository.Select(id);
            List<ParametersModel> paramModel = new List<ParametersModel>();
            foreach(var item in param)
            {
                ParametersModel model = new ParametersModel();
                model.NameId = item.ParamNameId;
                model.ValueId = item.ParamValueId;
                model.Name = ParametersRepository.FindName(item.ParamNameId);
                model.Value = ParametersRepository.FindValue(item.ParamValueId);
                paramModel.Add(model);
            }

            ViewBag.Param = paramModel;
            List<Picture> picture = PictureRepository.Select(id);
            ViewBag.Pictures = picture;
            ViewBag.Category = new CategoryRepository().Find(product.CategoryId).Name;
            return View(product);
        }
예제 #3
0
        //
        // GET: /Admin/EditProduct/5
        public ActionResult EditProduct(int id = 0)
        {
            Product product = repositoryProduct.Find(id);
            if (product == null)
            {
                return HttpNotFound();
            }
            List<Parameter> param = ParametersRepository.Select(id);
            List<ParametersModel> paramModel = new List<ParametersModel>();
            foreach (var item in param)
            {
                ParametersModel model = new ParametersModel();
                model.NameId = item.ParamNameId;
                model.ValueId = item.ParamValueId;
                model.Name = ParametersRepository.FindName(item.ParamNameId);
                model.Value = ParametersRepository.FindValue(item.ParamValueId);
                paramModel.Add(model);
            }

            ViewBag.Param = paramModel;
            List<Picture> picture = PictureRepository.Select(id);
            ViewBag.Pictures = picture;
            ViewBag.Categories = new CategoryRepository().Select().ToArray();
            return View(product);
        }
예제 #4
0
        public ActionResult ViewProduct(int productId)
        {
            var product = new ProductRepository().Find(productId);
            List<Parameter> param = ParametersRepository.Select(productId);
            List<ParametersModel> paramModel = new List<ParametersModel>();
            foreach (var item in param)
            {
                ParametersModel model = new ParametersModel();
                model.NameId = item.ParamNameId;
                model.ValueId = item.ParamValueId;
                model.Name = ParametersRepository.FindName(item.ParamNameId);
                model.Value = ParametersRepository.FindValue(item.ParamValueId);
                paramModel.Add(model);
            }

            ViewBag.Param = paramModel;
            List<Picture> picture = PictureRepository.Select(productId);
            ViewBag.Pictures = picture;
            ViewBag.Category = new CategoryRepository().Find(product.CategoryId).Name;
            ViewBag.Tags = TagRepository.GetStringTag(productId);
            ViewBag.IsStore = StoreRepository.Find(productId).Quantity > 0 ? true : false;
            var comments = new ProductRepository().SelectCommets(productId);
            ViewBag.UserNames = new UserRepository().SelectNamesByDescription(comments);
            ViewBag.Comments = comments;
            return View(product);
        }