public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CourseDescription")] Classes classes) { if (id != classes.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(classes); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassesExists(classes.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(classes)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email,ClassId")] Teachers teacher) { if (id != teacher.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(teacher); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TeachersExists(teacher.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClassId"] = new SelectList(_context.Classes, "Id", "Id", teacher.ClassId); return(View(teacher)); }
public async Task <IActionResult> Login(LoginViewModel l) { if (ModelState.IsValid) { //Проверка данных в БД Customer customer = await _cc.Customer.FirstOrDefaultAsync (c => c.Login == l.Login && c.Password == l.Password); if (customer != null) { //if (l.RememberMe) Properties.Resources.Remember = true; //else Properties.Resources.Remember = false; await Authenticate(l.Login); //аутентификация customer.RememberMe = l.RememberMe; _cc.Update(customer); await _cc.SaveChangesAsync(); return(RedirectToAction("Index", "Buy")); } else { ModelState.AddModelError("", "Некорректные логин или пароль"); } } return(View(l)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Email")] GroupMembers groupMembers) { if (id != groupMembers.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(groupMembers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GroupMembersExists(groupMembers.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(groupMembers)); }