示例#1
0
        public async Task <IActionResult> Login(LoginModel model)
        {
            MephiWebAppContext db = new MephiWebAppContext();

            if (ModelState.IsValid)
            {
                Auth user = await db.Auth.FirstOrDefaultAsync(u => u.Login == model.Login && u.Password == model.Password);

                if (user != null)
                {
                    await Authenticate(model.Login); // аутентификация

                    return(RedirectToAction("Table", "Home"));
                }
                ModelState.AddModelError("", "Некорректные логин и(или) пароль");
            }
            return(View(model));
        }
示例#2
0
        public IActionResult DeleteRoom(string corp, string n)   //удаление комнаты
        {
            MephiWebAppContext db = _db;
            // string Corp = Request.Query["corp"].ToString();
            //int Number = int.Parse(Request.Query["n"]);
            string Corp   = corp;
            int    Number = int.Parse(n);

            if (Corp == "" || Number < 100 || Number > 1300)
            {
                return(StatusCode(404));
            }
            var info_room = db.TRoom.FromSqlInterpolated($"SELECT * FROM t_room where pavilion = {Corp} AND number_room = {Number}").ToList();
            int i         = info_room[0].IdRoom;

            _db.Database.ExecuteSqlRaw($"DELETE FROM room_person WHERE id_room = {i}");                             //удаление связей с людьми

            _db.Database.ExecuteSqlRaw($"DELETE FROM t_room WHERE pavilion = '{Corp}' AND number_room = {Number}"); //удаление самой строки

            return(RedirectToAction("Table", "Home"));
        }
示例#3
0
 public Code1Controller(MephiWebAppContext db)
 {
     _db = db;
 }
示例#4
0
 public RelationController(MephiWebAppContext db)
 {
     _db = db;
 }
示例#5
0
 public HomeController(ILogger <HomeController> logger, MephiWebAppContext db)
 {
     _logger = logger;
     _db     = db;
 }