예제 #1
0
 public ActionResult DeleteAdmin(int id)
 {
     if (loginCheck() == false) { return RedirectToAction("LoggInn"); }
     var adminDb = new AdminBLL();
     AdminBruker enAdmin = adminDb.getSingleAdmin(id);
     return View(enAdmin);
 }
예제 #2
0
 public ActionResult DeleteAdmin(int id, AdminBruker slettKunde)
 {
     if (loginCheck() == false) { return RedirectToAction("LoggInn"); }
     var adminDb = new AdminBLL();
     bool slettOK = adminDb.deleteAdmin(id);
     if (slettOK)
     {
         return RedirectToAction("ListAdmins");
     }
     return View();
 }
예제 #3
0
 public ActionResult RegisterNewAdmin(AdminBruker innAdmin)
 {
     if (ModelState.IsValid)
     {
         var adminDb = new AdminBLL();
         bool insertOK = adminDb.insertAdmin(innAdmin);
         if (insertOK)
         {
             return RedirectToAction("ListAdmins");
         }
     }
     return View();
 }
예제 #4
0
        public ActionResult LoggInn(FormCollection innListe)
        {
            var brukernavn = innListe["Epost"];
            var passord = KundeBLL.hashPword(innListe["Passord"]);

            if (brukernavn.Equals("*****@*****.**") && passord.SequenceEqual(KundeBLL.hashPword("superuser")))
            {
                Session["Admin"] = true;
                Session["Superuser"] = true;

               return RedirectToAction("Index");
            }

            try
            {
                var db = new AdminBLL();
                var funnetBruker = db.getSingleAdminByEmail(brukernavn);

                if (funnetBruker == null)
                {
                    return View();
                }
                else
                {
                    if (funnetBruker.hashPassword.SequenceEqual(passord))
                    {
                        Session["Admin"] = true;

                        return RedirectToAction("Index");
                        // return "Kundenr: " + ((Kunde)Session["Bruker"]).KundeNR + " | Brukernavn: " + ((Kunde)Session["Bruker"]).Epost + " er logget inn!";
                    }
                    //return "funnetBruker.Passord: " + funnetBruker.Passord + " | innskrevet hash: " + passord;
                }

                return View();
            }
            catch (Exception feil)
            {

                return View(feil);
            }
        }
예제 #5
0
 ///ADMINBRUKERE////
 public ActionResult ListAdmins()
 {
     if (loginCheck() == false) { return RedirectToAction("LoggInn"); }
     var adminDb = new AdminBLL();
     List<AdminBruker> alleKunder = adminDb.getAll();
     return View(alleKunder);
 }
예제 #6
0
 public ActionResult EditAdmin(int id, AdminBruker endreAdmin)
 {
     if (loginCheck() == false) { return RedirectToAction("LoggInn"); }
     if (ModelState.IsValid)
     {
         var adminDb = new AdminBLL();
         bool endringOK = adminDb.changeAdmin(id, endreAdmin);
         if (endringOK)
         {
             return RedirectToAction("ListAdmins");
         }
     }
     return View();
 }