public ActionResult Index() { #region Set PopVM PopVM pop = new PopVM(); pop.Channels.AddRange(dbo.GetAllChannels()); IEnumerable <SelectListItem> popular = db.PopularContent .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Schedule.Show.Name, }); ViewBag.Pops = popular; IEnumerable <SelectListItem> schedules = db.Schedule .Select(c => new SelectListItem { Value = c.Id.ToString(), Text = c.Show.Name }); ViewBag.Schedule = schedules; #endregion return(View(pop)); }
public void UpdatePopularContent(PopVM model) { int popular = model.Id; PopularContent pc = new PopularContent(); pc = db.PopularContent.Find(popular); pc.ScheduleId = model.ScheduleId; pc.ImgUrl = "img/" + model.ImgUrl; pc.Icon = "mdi mdi-television"; db.Entry(pc).State = EntityState.Modified; db.SaveChanges(); }
public ActionResult GetForm(PopVM model) { if (ModelState.IsValid) { #region Update dbo.UpdatePopularContent(model); #endregion } else { ModelState.AddModelError(string.Empty, "En bild måste anges!"); } return(RedirectToAction("Index", "Admin")); }