Example #1
0
        public ActionResult LogOn(admindetails model, string returnUrl)
        {
            OnlineExamEntities4 db = new OnlineExamEntities4();

            if (ModelState.IsValid)
            {
                var admin = (from adminlist in db.Admins
                             where adminlist.Name == model.UserName && adminlist.Password == model.Password
                             select new
                {
                    adminlist.Name
                }).ToList();

                if (admin.FirstOrDefault() != null)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false);
                    return(RedirectToAction("Details", "Admin"));
                }
                else
                {
                    ModelState.AddModelError("", "Invalid login credentials.");
                }
            }
            return(View());
        }
Example #2
0
        public ActionResult Details()
        {
            admindetails viewdetails = db.Admins.Where(m => m.Name == User.Identity.Name).ToList().Select(val => new admindetails()
            {
                Id       = val.Id,
                UserName = val.Name,
                Password = val.Password
            }).SingleOrDefault();

            return(View(viewdetails));
        }
Example #3
0
        public ActionResult Edit(admindetails mod)
        {
            var user = db.Admins.Where(val => val.Id == mod.Id).SingleOrDefault <Admin>();

            user.Id   = mod.Id;
            user.Name = mod.UserName;
            db.SaveChanges();
            if (user.Name != null)
            {
                FormsAuthentication.SetAuthCookie(mod.UserName, false);
                return(RedirectToAction("Details", "Admin"));
            }
            return(View());
        }