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)); }
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")); }
public Code1Controller(MephiWebAppContext db) { _db = db; }
public RelationController(MephiWebAppContext db) { _db = db; }
public HomeController(ILogger <HomeController> logger, MephiWebAppContext db) { _logger = logger; _db = db; }