Exemple #1
0
 public ActionResult Edit(Artist artist, IEnumerable <HttpPostedFileBase> files)
 {
     if (ModelState.IsValid)
     {
         int i = 1;
         foreach (var file in files)
         {
             // Verify that the user selected a file
             if (file != null && file.ContentLength > 0)
             {
                 // extract only the fielname
                 var fileName = Path.GetFileName(file.FileName);
                 // store the file inside ~/App_Data/uploads folder
                 string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName;
                 var    path        = Path.Combine(Server.MapPath("~/Content/uploads"), "artist_" + newFileName);
                 file.SaveAs(path);
                 if (i == 1)
                 {
                     artist.BioImage = "/Content/uploads/artist_" + newFileName;
                 }
                 else
                 {
                     artist.HomePageImage = "/Content/uploads/artist_" + newFileName;
                 }
             }
             i++;
         }
         db.Entry(artist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(artist));
 }
 public ActionResult Edit(Image image, IEnumerable <HttpPostedFileBase> files)
 {
     if (ModelState.IsValid)
     {
         int i = 1;
         foreach (var file in files)
         {
             // Verify that the user selected a file
             if (file != null && file.ContentLength > 0)
             {
                 // extract only the fielname
                 var fileName = Path.GetFileName(file.FileName);
                 // store the file inside ~/App_Data/uploads folder
                 string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName;
                 var    path        = Path.Combine(Server.MapPath("~/Content/uploads"), newFileName);
                 file.SaveAs(path);
                 if (i == 1)
                 {
                     image.Thumb = "/Content/uploads/" + newFileName;
                 }
                 else
                 {
                     image.Normal = "/Content/uploads/" + newFileName;
                 }
             }
             i++;
         }
         db.Entry(image).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index", new { id = image.ArtistId }));
     }
     ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", image.ArtistId);
     return(View(image));
 }
Exemple #3
0
        public ActionResult Edit(EnterPage page, HttpPostedFileBase file)
        {
            try
            {
                //EnterPage ep = db.EnterPage.First();
                // Verify that the user selected a file
                if (file != null && file.ContentLength > 0)
                {
                    // extract only the fielname
                    var fileName = Path.GetFileName(file.FileName);
                    // store the file inside ~/App_Data/uploads folder
                    string newFileName = DateTime.Now.ToFileTimeUtc().ToString() + "_" + fileName;
                    var    path        = Path.Combine(Server.MapPath("~/Content/uploads"), newFileName);
                    file.SaveAs(path);
                    page.Image = "/Content/uploads/" + newFileName;
                }
                db.Entry(page).State = EntityState.Modified;
                //ep.Text = page.Text;
                db.SaveChanges();

                return(RedirectToAction("Index", "Admin"));
            }
            catch
            {
                return(View(db.EnterPage.First()));
            }
        }
Exemple #4
0
 public ActionResult Edit(MenuItem menuitem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(menuitem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(menuitem));
 }
Exemple #5
0
 public ActionResult Edit(SiteText sitetext)
 {
     if (ModelState.IsValid)
     {
         db.Entry(sitetext).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(sitetext));
 }