Пример #1
0
 public static bool IsOwner(Controller controller)
 {
     using (AircraftContext db = new AircraftContext())
     {
         return(db.Administrators.Where(m => m.Login == controller.User.Identity.Name).Single().AccessLevel == "Власник");
     }
 }
Пример #2
0
 //[ValidateAntiForgeryToken]
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         // поиск пользователя в бд
         Administrator user = null;
         using (AircraftContext db = new AircraftContext())
         {
             user = db.Administrators.FirstOrDefault(u => u.Login == model.Login && u.Password == model.Password);
         }
         if (user != null)
         {
             FormsAuthentication.SetAuthCookie(model.Login, true);
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "Користувача з таким логіном і паролем немає");
         }
     }
     return(View(model));
 }
Пример #3
0
 public AircraftController(AircraftContext context)
 {
     _context = context;
 }