Exemplo n.º 1
0
        //------------------------------------------------------
        //Редактирование средств по уходу
        public ActionResult EditCare(int ProductId)
        {
            Care          care = carerepo.GetProductById(ProductId);
            CareViewModel obj  = Mapper.Map <CareViewModel>(care);

            return(View(obj));
        }
Exemplo n.º 2
0
        //Добавление средств для ухода в категорию
        public ActionResult AddCare(int CategoryId)
        {
            TempData["CategoryName"] = repo.GetCategoryName(CategoryId);
            CareViewModel care = new CareViewModel();

            return(View("AddCare", care));
        }
Exemplo n.º 3
0
        public ActionResult EditCare(CareViewModel obj, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    obj.ImageMimeType = Image.ContentType;
                    obj.ImageData     = new byte[Image.ContentLength];
                    Image.InputStream.Read(obj.ImageData, 0, Image.ContentLength);
                }
                Care p = Mapper.Map <Care>(obj);
                carerepo.SaveProduct(p);
                TempData["message"] = String.Format("Изменения в товаре '{0}' сохранены", obj.ProductName);
                return(RedirectToAction("ShowProductsInCategory", "Admin", new { obj.CategoryId }));
            }

            else
            {
                return(View(obj));
            }
        }
Exemplo n.º 4
0
        public ActionResult AddCare(CareViewModel obj, HttpPostedFileBase Image)
        {
            if (ModelState.IsValid)
            {
                if (Image != null)
                {
                    obj.ImageMimeType = Image.ContentType;
                    obj.ImageData     = new byte[Image.ContentLength];
                    Image.InputStream.Read(obj.ImageData, 0, Image.ContentLength);
                }
                Care prod = Mapper.Map <Care>(obj);
                carerepo.SaveProduct(prod);
                TempData["message"] = String.Format("Товар '{0}' добавлен", obj.ProductName);
                return(RedirectToAction("Categories", "Admin"));
            }

            else
            {
                return(View(obj));
            }
        }