예제 #1
0
        public ActionResult ProductEdit(ProductModel model, HttpPostedFileBase Photo)
        {
            int id = int.Parse(Request.Form["hfId"]);
            Product product = _productService.Find(id);

            if (Photo != null)
            {
                var fileName = Path.GetFileNameWithoutExtension(Photo.FileName);
                var extension = Path.GetExtension(Photo.FileName);
                var fileFullName = Guid.NewGuid() + fileName.Replace(" ", "").Replace(".", "") + extension;
                var path = Path.Combine(Server.MapPath("~/Content/urun/haber"), fileFullName);
                Photo.SaveAs(path);
                product.Photo = "images/urun/" + fileFullName;
            }

            product.Active = model.Active;
            product.Content = model.Content;
            product.Order = model.Order;
            product.Name = model.Name;

            _productService.Update(product);
            _uow.SaveChanges();

            return RedirectToAction("ListProduct");
        }
예제 #2
0
        public ActionResult ProductAdd(ProductModel model, HttpPostedFileBase Photo)
        {
            if (Photo != null)
            {
                var fileName = Path.GetFileNameWithoutExtension(Photo.FileName);
                var extension = Path.GetExtension(Photo.FileName);
                var fileFullName = Guid.NewGuid() + fileName.Replace(" ", "").Replace(".", "") + extension;
                var path = Path.Combine(Server.MapPath("~/Content/images/urun"), fileFullName);
                Photo.SaveAs(path);

                Product product = new Product
                {
                    Active = model.Active,
                    Content = model.Content,
                    Photo = "images/urun/" + fileFullName,
                    Name = model.Name,
                    Order = model.Order
                };

                _productService.Insert(product);
                _uow.SaveChanges();
            }

            return RedirectToAction("ListProduct");
        }
예제 #3
0
        // GET: Admin/Product
        public ActionResult ListProduct()
        {
            ProductModel _productModel = new ProductModel();
            _productModel.ProductList = _productService.GetAll().ToList();

            return View(_productModel);
        }
예제 #4
0
        public ActionResult Edit(int id)
        {
            Product product = _productService.Find(id);

            ProductModel _productModel = new ProductModel
            {
                Id = product.Id,
                Active = product.Active,
                Content = product.Content,
                Name = product.Name,
                Order = product.Order,
            };

            return View(_productModel);
        }