예제 #1
0
        public ActionResult Create(Channel channel)
        {
            ModelState.Clear();
            channel.UserId = WebSecurity.GetUserId(User.Identity.Name);
            TryValidateModel(channel);

            if (ModelState.IsValid)
            {
                Context.Channels.Add(channel);
                Context.SaveChanges();

                return Roles.IsUserInRole(UserRole.Admin) ? RedirectToAction("Index") : RedirectToAction("IndexMy", "Broadcasts");
            }

            return View(channel);
        }
예제 #2
0
 public ActionResult Edit(Channel channel)
 {
     if (ModelState.IsValid)
     {
         Context.Entry(channel).State = EntityState.Modified;
         Context.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(channel);
 }