Exemple #1
0
        public IActionResult AddSubmit(Link link)
        {
            if (HttpContext.Session.GetString("auth") != "true")
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("Index", linkManager));
            }

            if (link.pinned == null)
            {
                link.pinned = "0";
            }
            else
            {
                link.pinned = "1";
            }

            linkManager.Add(link);
            linkManager.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #2
0
 public IActionResult SubmitAddLink(DBLink mydblink, string name, string link, int categoryID, bool pinnedToTop)
 {
     if (HttpContext.Session.GetString("auth") != "true")
     {
         return(RedirectToAction("Login", "Login"));
     }
     if (!ModelState.IsValid)
     {
         return(RedirectToAction("AdminIndex"));
     }
     try {
         Console.WriteLine("from submit" + name + link + categoryID + pinnedToTop);
         linkManager.Add(mydblink);
         linkManager.SaveChanges();
         if (pinnedToTop == true)
         {
             DBPinnedLink dbpinlink = new DBPinnedLink();
             dbpinlink.categoryID = categoryID;
             dbpinlink.name       = name;
             dbpinlink.link       = link;
             pinnedLinkManager.Add(dbpinlink);
             pinnedLinkManager.SaveChanges();
         }
     } catch (Exception e) {
         Console.WriteLine("Problem adding link" + e);
         TempData["adminFeedBack"] = "Unsuccessful addition of link";
     } finally {
         TempData["adminFeedBack"] = "Successful addition of link";
     }
     return(RedirectToAction("AdminIndex"));
 }