public ActionResult Edit([Bind(Include = "Link_List_ID,Page_ID,Name,Archived")] QuickLinkListEditViewModel viewMod) { if (ModelState.IsValid) { QuickLinkList qList = db.QuickLinkLists.Find(viewMod.Link_List_ID); if (qList != null) { qList.Name = viewMod.Name; if (viewMod.Archived && !qList.Archived) { qList.Date_Archived = DateTime.Now; qList.Archived_By = User.Identity.Name; } qList.Archived = viewMod.Archived; db.SaveChanges(); return(View(viewMod)); } else { ModelState.AddModelError("", "No Quick Link List found with the ID '" + viewMod.Link_List_ID + "'"); return(View(viewMod)); } } return(View(viewMod)); }
public ActionResult AddQuickLink(int Page_ID, int Link_List_ID, string Display_Text, string URL) { QuickLinkList qList = db.QuickLinkLists.Find(Link_List_ID); QuickLinkListEditViewModel viewMod = new QuickLinkListEditViewModel(qList, Page_ID); if (Display_Text.Trim() == "") { ModelState.AddModelError("", "'Display Text' must be filled out"); return(View("Edit", viewMod)); } else if (URL.Trim() == "") { ModelState.AddModelError("", "'URL' must be filled out"); return(View("Edit", viewMod)); } else { QuickLink link = new QuickLink(); link.URL = URL; link.Display_Text = Display_Text; link.Archived = false; link.Date_Added = DateTime.Now; link.Added_By = User.Identity.Name; link.Link_List_ID = Link_List_ID; db.QuickLinks.Add(link); db.SaveChanges(); return(RedirectToAction("Edit", new { Page_ID = Page_ID, Link_List_ID = Link_List_ID })); } }
public QuickLinkListEditViewModel(QuickLinkList list, int Page_ID) { this.Name = list.Name; this.Archived = list.Archived; this.Page_ID = Page_ID; this.quickLinks = list.QuickLinks.ToList(); this.Link_List_ID = list.Link_List_ID; }
public PageViewModel(Page page) { this.thisPage = page; this.Feedback_Message = ""; this.Feedback_Name = ""; if (this.thisPage.Banner != null) { this.thisPage.Banner.BannerElements = page.Banner.BannerElements.Where(x => x.Archived == false).ToList(); } this.assColls = this.thisPage.PageCollectionAssigns.Where(x => x.Archived == false).ToList(); this.assVidGals = this.thisPage.PageVideoGalleryAssigns.Where(x => x.Archived == false).ToList(); this.assCals = this.thisPage.PageCalenderAssigns.Where(x => x.Archived == false).ToList(); this.assLibs = this.thisPage.PageLibraryAssigns.Where(x => x.Archived == false).ToList(); this.assPhotoGals = this.thisPage.PageGalleryAssigns.Where(x => x.Archived == false).ToList(); this.assQuickLinkLists = this.thisPage.PageQuickLinkListsAssigns.Where(x => x.Archived == false).ToList(); this.collections = new List <Collection>(); this.calenders = new List <Calender>(); this.videoGalleries = new List <VideoGallery>(); this.libraries = new List <Library>(); this.photoGalleries = new List <Gallery>(); this.quickLinkLists = new List <QuickLinkList>(); foreach (var collIDAss in assColls.OrderBy(x => x.Sequence_No)) { Collection curColl = (from res in db.Collections where res.Collection_ID == collIDAss.Collection_ID select res).FirstOrDefault(); this.collections.Add(curColl); } foreach (var calIDAss in this.assCals) { Calender curCal = (from res in db.Calenders where res.Calender_ID == calIDAss.Calender_ID select res).FirstOrDefault(); this.calenders.Add(curCal); } foreach (var vidGalIDAss in this.assVidGals) { VideoGallery curVidGal = (from res in db.VideoGalleries where res.Video_Gallery_ID == vidGalIDAss.Video_Gallery_ID select res).FirstOrDefault(); this.videoGalleries.Add(curVidGal); } foreach (var libIDAss in this.assLibs) { Library curLib = (from res in db.Libraries where res.Library_ID == libIDAss.Library_ID select res).FirstOrDefault(); this.libraries.Add(curLib); } foreach (var photoGalIDAss in this.assPhotoGals) { Gallery photoGal = (from res in db.Galleries where res.Gallery_ID == photoGalIDAss.Gallery_ID select res).FirstOrDefault(); this.photoGalleries.Add(photoGal); } foreach (var quickLinkListIDAss in this.assQuickLinkLists) { QuickLinkList qList = (from res in db.QuickLinkLists where res.Link_List_ID == quickLinkListIDAss.Link_List_ID select res).FirstOrDefault(); this.quickLinkLists.Add(qList); } }
public ActionResult Edit(int Page_ID, int Link_List_ID) { QuickLinkList list = db.QuickLinkLists.Find(Link_List_ID); if (list == null) { return(HttpNotFound()); } QuickLinkListEditViewModel viewMod = new QuickLinkListEditViewModel(list, Page_ID); return(View(viewMod)); }
// GET: /QuickLinkLists/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuickLinkList quicklinklist = db.QuickLinkLists.Find(id); if (quicklinklist == null) { return(HttpNotFound()); } return(View(quicklinklist)); }
public ActionResult RemoveQuickLink(int Page_ID, int Link_List_ID, int Quick_Link_ID) { QuickLink link = db.QuickLinks.Find(Quick_Link_ID); if (link != null) { link.Archived = true; link.Date_Added = DateTime.Now; link.Archived_By = User.Identity.Name; db.SaveChanges(); return(RedirectToAction("Edit", new { Page_ID = Page_ID, Link_List_ID = Link_List_ID })); } else { QuickLinkList qList = db.QuickLinkLists.Find(Link_List_ID); QuickLinkListEditViewModel viewMod = new QuickLinkListEditViewModel(qList, Page_ID); ModelState.AddModelError("", "No Quick Link Found with the ID '" + Quick_Link_ID + "'"); return(View("Edit", viewMod)); } }
public ActionResult Create(string Name, int Page_ID) { QuickLinkList newList = new QuickLinkList(); newList.Name = Name; newList.Archived = false; newList.Date_Created = DateTime.Now; newList.Created_By = User.Identity.Name; db.QuickLinkLists.Add(newList); PageQuickLinkListsAssign qlAss = new PageQuickLinkListsAssign(); qlAss.Link_List_ID = newList.Link_List_ID; qlAss.Page_ID = Page_ID; qlAss.Date_Added = DateTime.Now; qlAss.Added_By = User.Identity.Name; qlAss.Archived = false; db.PageQuickLinkListsAssigns.Add(qlAss); db.SaveChanges(); return(RedirectToAction("Edit", new { Link_List_ID = newList.Link_List_ID, Page_ID = Page_ID })); }
public PageEditViewModel(Page page) { this.Page_ID = page.Page_ID; this.Page_Name = page.Page_Name; this.URL = page.URL; this.Title_Text = page.Title_Text; this.Is_Default = page.Is_Default; this.Parent_Page_ID = page.Parent_Page_ID; this.banner = page.Banner; this.Display_In_Menu = page.Display_In_Menu; this.Redirect = page.Redirect; this.Redirect_URL = page.Redirect_URL; this.Allow_Feedback = page.Allow_Feedback; this.Recipients_Temp = ""; this.allFeedback = page.Feedbacks.ToList(); this.collections = new List <Collection>(); this.galleries = new List <Gallery>(); this.libraries = new List <Library>(); this.calenders = new List <Calender>(); this.videoGalleries = new List <VideoGallery>(); this.availablePages = new List <Page>(); this.recipients = new List <NotificationRecipent>(); this.quickLinkLists = new List <QuickLinkList>(); this.assColls = page.PageCollectionAssigns.Where(x => x.Archived == false).ToList(); this.assVidGals = page.PageVideoGalleryAssigns.Where(x => x.Archived == false).ToList(); this.assCals = page.PageCalenderAssigns.Where(x => x.Archived == false).ToList(); this.assLibs = page.PageLibraryAssigns.Where(x => x.Archived == false).ToList(); this.assPhotoGals = page.PageGalleryAssigns.Where(x => x.Archived == false).ToList(); this.assQuickLinkLists = page.PageQuickLinkListsAssigns.Where(x => x.Archived == false).ToList(); this.assRecipients = page.PageRecipientAssigns.ToList(); availablePages = (List <Page>)(from pg in db.Pages where pg.Archived == false select pg).ToList(); availableBanners = (List <Banner>)(from b in db.Banners select b).ToList(); availableContentTypes = (List <ContentType>)(from c in db.ContentTypes select c).ToList(); foreach (var collIDAss in assColls.OrderBy(x => x.Sequence_No)) { Collection curColl = (from res in db.Collections where res.Collection_ID == collIDAss.Collection_ID select res).FirstOrDefault(); this.collections.Add(curColl); } foreach (var calIDAss in this.assCals) { Calender curCal = (from res in db.Calenders where res.Calender_ID == calIDAss.Calender_ID select res).FirstOrDefault(); this.calenders.Add(curCal); } foreach (var vidGalIDAss in this.assVidGals) { VideoGallery curVidGal = (from res in db.VideoGalleries where res.Video_Gallery_ID == vidGalIDAss.Video_Gallery_ID select res).FirstOrDefault(); this.videoGalleries.Add(curVidGal); } foreach (var libIDAss in this.assLibs) { Library curLib = (from res in db.Libraries where res.Library_ID == libIDAss.Library_ID select res).FirstOrDefault(); this.libraries.Add(curLib); } foreach (var photoGalIDAss in this.assPhotoGals) { Gallery photoGal = (from res in db.Galleries where res.Gallery_ID == photoGalIDAss.Gallery_ID select res).FirstOrDefault(); this.galleries.Add(photoGal); } foreach (var quickLinkListIDAss in this.assQuickLinkLists) { QuickLinkList qList = (from res in db.QuickLinkLists where res.Link_List_ID == quickLinkListIDAss.Link_List_ID select res).FirstOrDefault(); this.quickLinkLists.Add(qList); } foreach (var recipientsIDAss in this.assRecipients) { NotificationRecipent rec = (from res in db.NotificationRecipents where res.Recipient_ID == recipientsIDAss.Recipient_ID select res).FirstOrDefault(); this.recipients.Add(rec); this.Recipients_Temp += rec.Recipient_ID + "," + rec.Recipient_Name + "," + rec.Recipient_Email + "|"; } if (this.Recipients_Temp.Length > 0) { this.Recipients_Temp = this.Recipients_Temp.Substring(0, this.Recipients_Temp.Length - 1); } }
public QuickLinkListCreateViewModel(QuickLinkList list, int Page_ID) { this.Name = list.Name; this.Page_ID = Page_ID; }