public ActionResult Edit([Bind(Include = "TitleStatusID,TitleStatusName,Notes")] TitleStatus titleStatus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(titleStatus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(titleStatus));
 }
Example #2
0
 public ActionResult Edit([Bind(Include = "WriterID,FirstName,LastName,Country")] Writer writer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(writer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(writer));
 }
 public ActionResult Edit([Bind(Include = "GenreID,GenreName")] Genre genre)
 {
     if (ModelState.IsValid)
     {
         db.Entry(genre).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genre));
 }
Example #4
0
 public ActionResult Edit([Bind(Include = "StudioID,StudioName,Country,IsActive")] Studio studio)
 {
     if (ModelState.IsValid)
     {
         db.Entry(studio).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(studio));
 }
Example #5
0
 public ActionResult Edit([Bind(Include = "CustomerID,FirstName,LastName,Address")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
 public ActionResult Edit([Bind(Include = "VendorID,VendorName,ContactName,PhoneNumber")] Vendor vendor)
 {
     if (ModelState.IsValid)
     {
         db.Entry(vendor).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(vendor));
 }
Example #7
0
 public ActionResult Edit([Bind(Include = "SupplierID,CompanyName,City,State,Phone")] Supplier supplier)
 {
     if (ModelState.IsValid)
     {
         db.Entry(supplier).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(supplier));
 }
Example #8
0
 public ActionResult Edit([Bind(Include = "DimensionID,DimensionRange")] Dimension dimension)
 {
     if (ModelState.IsValid)
     {
         db.Entry(dimension).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(dimension));
 }
 public ActionResult Edit([Bind(Include = "ProductType1,TypeName")] ProductType productType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productType));
 }
Example #10
0
 public ActionResult Edit([Bind(Include = "ID,Name,Description")] ProductStatus productStatus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(productStatus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(productStatus));
 }
 [Authorize(Roles = "Admin, Sales")]//ADMIN and SALES only
 public ActionResult Edit([Bind(Include = "FitID,FitName")] Fit fit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(fit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(fit));
 }
 public ActionResult Edit([Bind(Include = "StatusID1,Status")] StatusID statusID)
 {
     if (ModelState.IsValid)
     {
         db.Entry(statusID).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(statusID));
 }
Example #13
0
 public ActionResult Edit([Bind(Include = "BrandID,BrandName")] Brand brand)
 {
     if (ModelState.IsValid)
     {
         db.Entry(brand).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brand));
 }
Example #14
0
 public ActionResult Edit([Bind(Include = "ManufacturerID,ManufacturerName,City,State,Country")] Manufacturer manufacturer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manufacturer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(manufacturer));
 }
Example #15
0
 public ActionResult Edit([Bind(Include = "CategoryID,Name,Comments")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Example #16
0
 public ActionResult Edit([Bind(Include = "SeasonID,Season1")] Season season)
 {
     if (ModelState.IsValid)
     {
         db.Entry(season).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(season));
 }
Example #17
0
 public ActionResult Edit([Bind(Include = "DeptID,DeptName")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
Example #18
0
 public ActionResult Edit([Bind(Include = "InventoryStatusID,InventoryStatusName,Comments")] InventoryStatus inventoryStatus)
 {
     if (ModelState.IsValid)
     {
         db.Entry(inventoryStatus).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(inventoryStatus));
 }
 public ActionResult Edit([Bind(Include = "MaterialID,MaterialName")] Material material)
 {
     if (ModelState.IsValid)
     {
         db.Entry(material).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(material));
 }
 public ActionResult Edit([Bind(Include = "InvID,InvName")] InvStatu invStatu)
 {
     if (ModelState.IsValid)
     {
         db.Entry(invStatu).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(invStatu));
 }
Example #21
0
        public ActionResult Edit([Bind(Include = "ProductID,ProductName,Price,UnitsSold,TypeID,MakeID,Model,ProductStatusID,Description,ProductImage,IsFeatured")] Product product, HttpPostedFileBase productImage)
        {
            if (ModelState.IsValid)
            {
                #region File Edit
                string file = "noImage.png";

                if (productImage != null)
                {
                    // The user has uploaded a file to include for that specific book.
                    file = productImage.FileName;
                    // Check that the uploaded file extension matches accepted extensions
                    string   ext      = file.Substring(file.LastIndexOf('.'));
                    string[] goodExts = { ".jpg", ".jpeg", ".png", ".gif" };

                    // Check that the file extension is in our list of acceptable extensions AND check that the file size is 4MB MAX
                    if (goodExts.Contains(ext.ToLower()) && productImage.ContentLength <= 5242880)
                    {
                        // Create a new file name (using a GUID)
                        file = Guid.NewGuid() + ext;

                        #region Resize Image
                        // This informs the program to save the image to this location in our file structure.
                        string savePath = Server.MapPath("~/Content/images/");

                        Image convertedImage = Image.FromStream(productImage.InputStream);

                        int maxImageSize = 400;

                        int maxThumbSize = 100;

                        ImageServices.ResizeImage(savePath, file, convertedImage, maxImageSize, maxThumbSize);
                        #endregion

                        // The code below will delete the old image from the file structure.
                        if (product.ProductImage != null && product.ProductImage != "noImage.png")
                        {
                            string path = Server.MapPath("~/Content/images/");
                            ImageServices.Delete(path, product.ProductImage);
                        }
                    }
                }

                // No matter what, update the photoUrl with the value of the file variable
                product.ProductImage = file;
                #endregion
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.MakeID          = new SelectList(db.ProductMakes, "MakeID", "MakeName", product.MakeID);
            ViewBag.ProductStatusID = new SelectList(db.ProductStatuses, "ProductStatusID", "ProductStatusName", product.ProductStatusID);
            ViewBag.TypeID          = new SelectList(db.ProductTypes, "TypeID", "TypeName", product.TypeID);
            return(View(product));
        }
Example #22
0
 public ActionResult Edit([Bind(Include = "ModelID,BrandID,ModelName")] ModelCategory modelCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(modelCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BrandID = new SelectList(db.Brands, "BrandID", "BrandName", modelCategory.BrandID);
     return(View(modelCategory));
 }
Example #23
0
        public ActionResult Edit([Bind(Include = "SeedID,CommonName,ScientificName,Description,PlantingInstructions,Cost,SpacingID,UnitsID,CycleID,ProductID,SproutID,SeasonID,CategoryID,SunID,TempID,GeneID,DepthID,FrostID,ImageUrl")] Seed seed, HttpPostedFileBase seedPacket)
        {
            if (ModelState.IsValid)
            {
                #region File Upload Utility
                if (seedPacket != null)
                {
                    string imgName = seedPacket.FileName;

                    string ext = imgName.Substring(imgName.LastIndexOf('.'));

                    string[] goodExts = { ".jpg", ".jpeg", ".gif", ".png" };

                    if (goodExts.Contains(ext.ToLower()) && (seedPacket.ContentLength <= 4194304))
                    {
                        imgName = Guid.NewGuid() + ext.ToLower();

                        string savePath = Server.MapPath("~/Content/img/product/");

                        Image convertedImage = Image.FromStream(seedPacket.InputStream);
                        int maxImageSize = 500;
                        int maxThumbSize = 100;

                        ImageService.ResizeImage(savePath, imgName, convertedImage, maxImageSize, maxThumbSize);

                        if (seed.ImageUrl != null && seed.ImageUrl != "NoImage.png")
                        {
                            string path = Server.MapPath("~/Content/img/product/");
                            ImageService.Delete(path, seed.ImageUrl);
                        }
                        seed.ImageUrl = imgName;

                    }//end if
                }
                #endregion
                ctx.Entry(seed).State = EntityState.Modified;
                ctx.SaveChanges();
                return RedirectToAction("SeedsMVCPaging");
            }
            ViewBag.FrostID = new SelectList(ctx.FrostHardys, "FrostID", "FrostID", seed.FrostID);
            ViewBag.GeneID = new SelectList(ctx.GeneTypes, "GeneID", "GeneName", seed.GeneID);
            ViewBag.TempID = new SelectList(ctx.IdealTemps, "TempID", "Temp", seed.TempID);
            ViewBag.CycleID = new SelectList(ctx.LifeCycles, "CycleID", "CycleType", seed.CycleID);
            ViewBag.SunID = new SelectList(ctx.MinFullSuns, "SunID", "SunTime", seed.SunID);
            ViewBag.SpacingID = new SelectList(ctx.PlantSpacings, "SpacingID", "Spacing", seed.SpacingID);
            ViewBag.ProductID = new SelectList(ctx.Products, "ProductID", "ProductName", seed.ProductID);
            ViewBag.SeasonID = new SelectList(ctx.Seasons, "SeasonID", "SeasonType", seed.SeasonID);
            ViewBag.CategoryID = new SelectList(ctx.SeedCategories, "CategoryID", "CategoryName", seed.CategoryID);
            ViewBag.DepthID = new SelectList(ctx.SeedDepths, "DepthID", "DepthID", seed.DepthID);
            ViewBag.SproutID = new SelectList(ctx.SproutIns, "SproutID", "SproutDays", seed.SproutID);
            ViewBag.UnitsID = new SelectList(ctx.UnitsPerPackets, "UnitsID", "UnitsID", seed.UnitsID);
            return View(seed);
        }
Example #24
0
        public ActionResult Edit([Bind(Include = "ProductID,ProductName,CategoryID,Size,Price,InStock,UnitsInStock,Condition,Source,SupplierID,ProductImage,Description")] Product product)
        {
            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "CategoryName", product.CategoryID);

            return(View(product));
        }
Example #25
0
 public ActionResult Edit([Bind(Include = "EmpID,FirstName,LastName,Position,ReportsTo,DeptID")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DeptID    = new SelectList(db.Departments, "DeptID", "DeptName", employee.DeptID);
     ViewBag.ReportsTo = new SelectList(db.Employees, "EmpID", "FirstName", employee.ReportsTo);
     return(View(employee));
 }
 public ActionResult Edit([Bind(Include = "ProductID,ProductName,ProductType,Description,Price,ProductImage,VendorID")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductType = new SelectList(db.ProductTypes, "ProductType1", "TypeName", product.ProductType);
     ViewBag.VendorID    = new SelectList(db.Vendors, "VendorID", "VendorName", product.VendorID);
     return(View(product));
 }
 public ActionResult Edit([Bind(Include = "MovieTVDirectorID,MovieTVID,DirectorID,DirectorOrder")] MovieTVDirector movieTVDirector)
 {
     if (ModelState.IsValid)
     {
         db.Entry(movieTVDirector).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DirectorID = new SelectList(db.Directors, "DirectorID", "FullName", movieTVDirector.DirectorID);
     ViewBag.MovieTVID  = new SelectList(db.MoviesTVs, "MovieTVID", "Title", movieTVDirector.MovieTVID);
     return(View(movieTVDirector));
 }
 public ActionResult Edit([Bind(Include = "OddityID,OddityName,OriginID,RecoveryDate,Price,OddityStatusID,GenreID,UnitsSold")] Oddity oddity)
 {
     if (ModelState.IsValid)
     {
         db.Entry(oddity).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.GenreID        = new SelectList(db.Genres, "GenreID", "Genre1", oddity.GenreID);
     ViewBag.OddityStatusID = new SelectList(db.OddityStatus, "OddityStatusID", "Status", oddity.OddityStatusID);
     ViewBag.OddityID       = new SelectList(db.Origins, "OriginID", "Origin1", oddity.OddityID);
     return(View(oddity));
 }
Example #29
0
        public ActionResult Edit([Bind(Include = "MovieTVID,DiscTypeID,RegionCodeID,UPC,TitleTypeID,Title,Description,GenreID,Runtime,MPAARatingID,Price,UnitsSold,ReleaseDate,StudioID,TitleImage,IsSiteFeature,IsOnSaleFeature,TitleStatusID")] MoviesTV moviesTV, HttpPostedFileBase titleCover)
        {
            if (ModelState.IsValid)
            {
                #region File Upload
                if (titleCover != null)
                {
                    string   file     = titleCover.FileName;
                    string   ext      = file.Substring(file.LastIndexOf('.'));
                    string[] goodExts = { ".jpeg", ".jpg", ".png", ".gif" };
                    //check that the uploaded file ext is in our list of good file extensions
                    if (goodExts.Contains(ext))
                    {
                        //if valid ext, check file size <= 4mb (max by default from ASP.NET)
                        if (titleCover.ContentLength <= 4194304)
                        {
                            //create a new file name using a guid
                            //file = Guid.NewGuid() + ext;

                            #region Resize Image
                            string savePath       = Server.MapPath("~/Content/img/MoviesTV/");
                            Image  convertedImage = Image.FromStream(titleCover.InputStream);
                            int    maxImageSize   = 650;
                            int    maxThumbSize   = 250;
                            ImageUploadUtility.ResizeImage(savePath, file, convertedImage, maxImageSize, maxThumbSize);
                            #endregion

                            if (moviesTV.TitleImage != null && moviesTV.TitleImage != "NoImage.png")
                            {
                                string path = Server.MapPath("~/Content/img/MoviesTV/");
                                ImageUploadUtility.Delete(path, moviesTV.TitleImage);
                            }
                        }
                    }
                    moviesTV.TitleImage = file;
                }
                #endregion
                db.Entry(moviesTV).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.GenreID       = new SelectList(db.Genres, "GenreID", "GenreName", moviesTV.GenreID);
            ViewBag.StudioID      = new SelectList(db.Studios, "StudioID", "StudioName", moviesTV.StudioID);
            ViewBag.TitleStatusID = new SelectList(db.TitleStatuses, "TitleStatusID", "TitleStatusName", moviesTV.TitleStatusID);
            ViewBag.DiscTypeID    = new SelectList(db.DiscTypes, "DiscTypeID", "DiscTypeName", moviesTV.DiscTypeID);
            ViewBag.TitleTypeID   = new SelectList(db.TitleTypes, "TitleTypeID", "TitleTypeName", moviesTV.TitleTypeID);
            ViewBag.RegionCodeID  = new SelectList(db.RegionCodes, "RegionCodeID", "RegionCodeID", moviesTV.RegionCodeID);
            ViewBag.MPAARatingID  = new SelectList(db.MPAARatings, "MPAARatingID", "Rating", moviesTV.MPAARatingID);
            return(View(moviesTV));
        }
 public ActionResult Edit([Bind(Include = "ID,Name,Description,Price,CategoryID,ManufacturerID,ProductStatusID,CandyTypeID,ProductImage")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CandyTypeID     = new SelectList(db.CandyTypes, "ID", "Name", product.CandyTypeID);
     ViewBag.CategoryID      = new SelectList(db.Categories, "ID", "Name", product.CategoryID);
     ViewBag.ManufacturerID  = new SelectList(db.Manufacturers, "ID", "Name", product.ManufacturerID);
     ViewBag.ProductStatusID = new SelectList(db.ProductStatuses, "ID", "Name", product.ProductStatusID);
     return(View(product));
 }