Exemplo n.º 1
0
 public ActionResult Edit(ArtistModel artistmodel)
 {
     if (ModelState.IsValid)
     {
         db.Entry(artistmodel).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(artistmodel);
 }
Exemplo n.º 2
0
        public ActionResult Create(ArtistModel artistmodel)
        {
            if (ModelState.IsValid)
            {
                db.Artists.Add(artistmodel);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(artistmodel);
        }
        public ActionResult Create(ArtistModel artistmodel)
        {
            if (ModelState.IsValid)
            {
                artistmodel.UserId = User.Identity.Name;
                Db.Artists.Add(artistmodel);
                Db.SaveChanges();
                return RedirectToAction("Index");
            }

            LoadDropDowns(null, null);
            return View("Create", User.IsInRole("Admin") ? "_Layout" : "_PublicLayout", artistmodel);
        }
        public ActionResult Edit(ArtistModel artistmodel)
        {
            if (
                !User.IsInRole("Admin")
                && artistmodel.UserId != User.Identity.Name
            )
            {
                return View("NotYourArtist");
            }

            if (ModelState.IsValid)
            {
                Db.Entry(artistmodel).State = EntityState.Modified;
                Db.SaveChanges();
                return RedirectToAction("Index");
            }

            LoadDropDowns(artistmodel.ArtistTypeId, artistmodel.ArtistSubTypeId);
            return View(artistmodel);
        }