Esempio n. 1
0
 public ActionResult Edit(Artist artist, HttpPostedFileBase image)
 {
     if (ModelState.IsValid)
     {
         this.SaveFile(image, artist.Id, "Image/Artist");
         db.Entry(artist).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(artist));
 }
Esempio n. 2
0
 public ActionResult ModifyAddress(AddressBook model, string returnUrl)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     using (var db = new MKContext())
     {
         db.Entry(model).State = EntityState.Modified;
         db.SaveChanges();
     }
     return(RedirectToLocal(returnUrl));
 }
Esempio n. 3
0
        public ActionResult Edit(Item item, HttpPostedFileBase image, HttpPostedFileBase audition, HttpPostedFileBase download)
        {
            if (ModelState.IsValid)
            {
                db.Entry(item).State = EntityState.Modified;
                db.SaveChanges();
                SaveDataEx(item, image, audition, download);
                return(RedirectToAction("Index"));
            }

            ViewBag.AlbumId    = new SelectList(db.Items, "Id", "ItemName", item.AlbumId);
            ViewBag.ArtistId   = new SelectList(db.Artists, "Id", "ArtistName", item.ArtistId);
            ViewBag.CategoryId = new SelectList(db.Categories, "Id", "CategoryName", item.CategoryId);
            return(View(item));
        }
Esempio n. 4
0
 public ActionResult Edit(UserEditModel model)
 {
     if (ModelState.IsValid)
     {
         db.Entry(model.User).State = EntityState.Modified;
         db.SaveChanges();
         if (model.IsAdmin)
         {
             if (!Roles.IsUserInRole(model.User.UserName, "Admin"))
             {
                 Roles.AddUserToRole(model.User.UserName, "Admin");
             }
         }
         else
         {
             if (Roles.IsUserInRole(model.User.UserName, "Admin"))
             {
                 Roles.RemoveUserFromRole(model.User.UserName, "Admin");
             }
         }
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }