/// <summary> /// Displays a resource's details /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult ResourceDetail(int id) { if (!IsLoggedIn) { return(RedirectToAction("Index")); } var r = Db.Resources.Single(rs => rs.ID == id); var model = new AdminResourceDetailViewModel { ResourceID = id, Languages = Db.Languages.ToList(), ResourceDetails = r.ResourceDetails.ToList() }; return(View(model)); }
public ActionResult ResourceDetailAdd(AdminResourceDetailViewModel model) { if (!IsLoggedIn) { return(RedirectToAction("Index")); } var rd = new ResourceDetail { Title = model.Title, Description = model.Description, ShortDescription = model.ShortDescription, OpeningHours = model.OpeningHours, Address = model.Address, Language = Db.Languages.Single(l => l.ID == model.LanguageID), Resource = Db.Resources.Single(c => c.ID == model.ResourceID) }; Db.ResourceDetails.Add(rd); Db.SaveChanges(); return(RedirectToAction("ResourceDetail", new { id = model.ResourceID })); }