Exemplo n.º 1
0
        public ActionResult Create([Bind(Include = "ProductId,BrandId,CategoryId,Name,Price,IsNew,IsSale,IsActive,ProductDetails")] Products products,
                                   HttpPostedFileBase file, string editor1, IEnumerable <HttpPostedFileBase> files)
        {
            if (ModelState.IsValid)
            {
                ImageUpload imageUpload = new ImageUpload();
                if (file != null)
                {
                    products.ImageURL = imageUpload.ImageResize(file, 255, 237);
                }
                products.ProductDetails.Description = editor1;
                products.RegisterDate = DateTime.Now;
                if (files.FirstOrDefault() != null)
                {
                    foreach (var item in files)
                    {
                        var paths = imageUpload.ImageResize(item, 84, 84, 329, 380);
                        products.ProductDetails.Images.Add(new Images
                        {
                            ImageURL  = paths.Item1,
                            ImageURLt = paths.Item2
                        });
                    }
                }
                db.Products.Add(products);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BrandId    = new SelectList(db.Brands, "BrandId", "Name", products.BrandId);
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", products.CategoryId);
            ViewBag.ProductId  = new SelectList(db.ProductDetails, "ProductId", "Description", products.ProductId);
            return(View(products));
        }
Exemplo n.º 2
0
        public ActionResult Create([Bind(Include = "SliderId,ImageUrl,RegisterDate")] Slider slider, IEnumerable <HttpPostedFileBase> files)
        {
            ImageUpload imageUpload = new ImageUpload();

            if (ModelState.IsValid)
            {
                if (files.FirstOrDefault() != null) //ikinci olarak kontrol yazılır ÇOKLU image için
                {
                    foreach (var item in files)
                    {
                        var image = imageUpload.ImageResize(item, 84, 84, 1140, 475);
                        db.Slider.Add(new  Slider
                        {
                            ImageUrl = image.Item1,

                            RegisterDate = DateTime.Now
                        });
                    }
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(slider));
        }
        [ValidateInput(false)]//ckeditör için  html kod doğrulama isteği

        public ActionResult Edit([Bind(Include = "ProductId,CategoryId,Name,Price,Description,Image")] Products products, HttpPostedFileBase file, string editor1)
        {
            if (ModelState.IsValid)
            {
                ImageUpload imgUpload = new ImageUpload();
                var         product   = db.Products.Find(products.ProductId);
                if (file != null)
                {
                    //resim yükleme işlemi
                    product.Image = imgUpload.ImageResize(file, 240, 240);
                }

                product.Categories  = products.Categories;
                product.CategoryId  = products.CategoryId;
                product.Description = editor1;
                product.Name        = products.Name;
                product.Price       = products.Price;


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", products.CategoryId);
            return(View(products));
        }
Exemplo n.º 4
0
        public ActionResult ProductProcess(Product entity, HttpPostedFileBase file, string isNew)
        {
            if (file != null && file.ContentLength > 0 && file.ContentLength < 10485760)
            {
                ImageUpload imageUpload = new ImageUpload();

                string imagePath = imageUpload.ImageResize(file, 673, 483);

                if (isNew != "true")
                {
                    string filePath = Server.MapPath(entity.PictureUrl);
                    if (System.IO.File.Exists(filePath))
                    {
                        System.IO.File.Delete(filePath);
                    }
                }

                entity.PictureUrl = imagePath;
            }

            if (isNew == "true")
            {
                int addResult = proMng.Add(entity);
            }
            else
            {
                bool updateResult = proMng.Update(entity);
            }

            return(RedirectToAction("UrunIslemleri", "Product"));
        }
Exemplo n.º 5
0
        [ValidateInput(false)]//ckeditör için  html kod doğrulama isteği

        public ActionResult Edit([Bind(Include = "HomeId,LogoImgUrl,DescriptionOneTitle,DescriptionOne,DescriptionTwoTitle,DescriptionTwo")] Home home, HttpPostedFileBase file, string editor1, string editor2)
        {
            if (ModelState.IsValid && db.Home.Count() == 1)
            {
                ImageUpload imgUpload   = new ImageUpload();
                var         editedModel = db.Home.Find(home.HomeId);
                if (file != null)
                {
                    //resim yükleme işlemi
                    editedModel.LogoImgUrl = imgUpload.ImageResize(file, 240, 240);
                }



                editedModel.DescriptionOne      = editor1;
                editedModel.DescriptionOneTitle = home.DescriptionOneTitle.ToString();
                editedModel.DescriptionTwoTitle = home.DescriptionTwoTitle.ToString();
                editedModel.DescriptionTwo      = editor2;


                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(home));
        }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "ProductId,BrandId,CategoryId,Name,Price,IsNew,IsSale,IsActive,ProductDetails")] Products products,
                          HttpPostedFileBase file, string editor1, IEnumerable <HttpPostedFileBase> editeFiles)
 {
     if (ModelState.IsValid)
     {
         var editToProduct = db.Products.Find(products.ProductId);
         editToProduct.BrandId    = products.BrandId;
         editToProduct.CategoryId = products.CategoryId;
         ImageUpload imageUpload = new ImageUpload();
         if (file != null)
         {
             editToProduct.ImageURL = imageUpload.ImageResize(file, 255, 237);
         }
         editToProduct.IsActive = products.IsActive;
         editToProduct.IsNew    = products.IsNew;
         editToProduct.IsSale   = products.IsSale;
         editToProduct.Name     = products.Name;
         editToProduct.Price    = products.Price;
         editToProduct.ProductDetails.Description = editor1;
         editToProduct.ProductDetails.IsCondition = products.ProductDetails.IsCondition;
         editToProduct.ProductDetails.WebId       = products.ProductDetails.WebId;
         if (editeFiles.FirstOrDefault() != null)
         {
             foreach (var item in editeFiles)
             {
                 var paths = imageUpload.ImageResize(item, 84, 84, 329, 380);
                 editToProduct.ProductDetails.Images.Add(new Images
                 {
                     ImageURL  = paths.Item1,
                     ImageURLt = paths.Item2
                 });
             }
         }
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     db.SaveChanges();
     ViewBag.BrandId    = new SelectList(db.Brands, "BrandId", "Name", products.BrandId);
     ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", products.CategoryId);
     ViewBag.ProductId  = new SelectList(db.ProductDetails, "ProductId", "Description", products.ProductId);
     return(View(products));
 }
        public ActionResult Create([Bind(Include = "RefId,Title,Image,RefName")] Referances referances, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    ImageUpload imageUpload = new ImageUpload();
                    referances.Image = imageUpload.ImageResize(file, 255, 237);
                }
                db.Referances.Add(referances);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(referances));
        }
        [ValidateInput(false)]//ckeditör için  html kod doğrulama isteği

        public ActionResult Create([Bind(Include = "ProductId,CategoryId,Name,Price,Description,Image")] Products products, HttpPostedFileBase file, string editor1)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    ImageUpload imageUpload = new ImageUpload();
                    products.Image = imageUpload.ImageResize(file, 255, 237);
                }
                products.Description = editor1;
                db.Products.Add(products);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CategoryId = new SelectList(db.Categories, "CategoryId", "Name", products.CategoryId);
            return(View(products));
        }
Exemplo n.º 9
0
        public ActionResult Create([Bind(Include = "HomeId,Name,DescriptionOneTitle,DescriptionOne,DescriptionOneUrl,DescriptionTwoTitle,DescriptionTwo")] Home home, HttpPostedFileBase file, string editor1, string editor2)
        {
            if (ModelState.IsValid && db.Home.Count() == 0)
            {
                if (file != null)
                {
                    ImageUpload imageUpload = new ImageUpload();
                    home.LogoImgUrl = imageUpload.ImageResize(file, 255, 237);
                }
                home.DescriptionOne = editor1;
                home.DescriptionTwo = editor2;
                db.Home.Add(home);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(home));
        }
Exemplo n.º 10
0
        public ActionResult Edit([Bind(Include = "SliderId,ImageUrl,RegisterDate")] Slider slider, HttpPostedFileBase file)
        {
            ImageUpload imageUpload = new ImageUpload();

            if (ModelState.IsValid)
            {
                if (file != null)//ikinci olarak kontrol yazılır ÇOKLU image için
                {
                    var image = imageUpload.ImageResize(file, 84, 84, 1140, 475);
                    slider.ImageUrl     = image.Item1;
                    slider.RegisterDate = DateTime.Now;
                }
                slider.RegisterDate    = DateTime.Now;
                db.Entry(slider).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(slider));
        }
        protected void btnCreate_Click(object sender, EventArgs e)
        {
            DenemeDbEntities db          = new DenemeDbEntities();
            ImageUpload      imageUpload = new ImageUpload();
            var paths = imageUpload.ImageResize(fuImage);

            db.Product.Add(new Product
            {
                Description  = txtDescription.Text,
                IsActive     = chkIsActive.Checked,
                ProductName  = txtProductName.Text,
                RegisterDate = DateTime.Now,
                UnitPrice    = Convert.ToSingle(txtUnitPrice.Text),
                UnitsInStock = Convert.ToInt16(txtUnitsInStock.Text),
                ImageURL     = paths.Item1,
                ImageURLt    = paths.Item2
            });
            db.SaveChanges();
        }
        public ActionResult Edit([Bind(Include = "RefId,Title,Image,RefName")] Referances referances, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                ImageUpload imgUpload = new ImageUpload();
                var         edited    = db.Referances.Find(referances.RefId);
                if (file != null)
                {
                    //resim yükleme işlemi
                    edited.Image = imgUpload.ImageResize(file, 240, 240);
                }

                edited.Title   = referances.Title;
                edited.RefName = referances.RefName;



                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(referances));
        }