public ActionResult Create(int SliderId, List <int> NewId) { if (Request.Cookies["MagazineId"].Value == null) { SetMessage("Lo sentimos, ha ocurrido un error. Inténtelo de nuevo.", BootstrapAlertTypes.Danger); return(RedirectToAction("Index", "Magazines")); } int magId = Int32.Parse(Request.Cookies["MagazineId"].Value); var user = UserService.GetCurrentUser(); var relation = UserService.UserInMagazine(magId, user.UserId); if (!relation) { return(RedirectToAction("Index", "Magazines")); } var order = db.SlidesList.Where(x => x.SliderId == SliderId).OrderByDescending(x => x.Order).Take(1).Select(x => x.Order).First(); var slide = new Slide(); foreach (var item in NewId) { slide = new Slide { NewsId = item, SliderId = SliderId, Order = order }; db.SlidesList.Add(slide); db.Save(); order++; } SetMessage("Tus slides fueron agregados con éxito.", BootstrapAlertTypes.Success); return(RedirectToAction("Index")); }