public async Task <IActionResult> Edit(int id, [Bind("Did,Name,Gender")] Directors directors) { if (id != directors.Did) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(directors); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DirectorsExists(directors.Did)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(directors)); }
public async Task <IActionResult> Edit(int id, [Bind("MovieId,Cid,DirectorId,Title,ReleaseYear")] Movies movies) { if (id != movies.MovieId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movies); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MoviesExists(movies.MovieId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Cid"] = new SelectList(_context.Customers, "Cid", "Name", movies.Cid); ViewData["DirectorId"] = new SelectList(_context.Directors, "Did", "Name", movies.DirectorId); return(View(movies)); }
public async Task <IActionResult> Edit(int id, [Bind("Cid,Name,Dob,Email,Phone")] Customers customers) { if (id != customers.Cid) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customers); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomersExists(customers.Cid)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <AuthDTO_Out> AuthenticateAsync(AuthDTO_In authDTO, string ipAddress) { //check if the user exist var user = await this.context.Users .Include(u => u.Refresh_Tokens) .SingleOrDefaultAsync(u => u.Email == authDTO.Email); if (user == null) { return(null); } //check if for the password match if (!VerifyPasswordHash(authDTO.Password, user.PasswordHash, user.PasswordSalt)) { return(null); } //create the JWT token and return var JWTToken = this.GenerateJWTToken(user); var refreshToken = this.generateRefreshToken(ipAddress); // save refresh token user.Refresh_Tokens.Add(refreshToken); context.Update(user); await context.SaveChangesAsync(); return(new AuthDTO_Out { Id = user.Id, FirstName = user.FirstName, LastName = user.LastName, Email = user.Email, Token = JWTToken, RefreshToken = refreshToken.Token }); }
public async Task <IActionResult> Edit([Bind("CustomerId,PersonalId,FirstName,FamilyName,Email,PhoneNumber,Address,Gender,Birthday")] Customer customer) { if (ModelState.IsValid) { if (_context.Customer.AsNoTracking().SingleOrDefault(x => x.CustomerId == customer.CustomerId) != null) { _context.Update(customer); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } return(View(customer)); }
public async Task <IActionResult> Edit([Bind("MovieId,CustomerId,LoanDate,ReturnDate")] Loan loan) { if (ModelState.IsValid) { if (_context.Loan.AsNoTracking().SingleOrDefault(l => l.CustomerId == loan.CustomerId && l.MovieId == loan.MovieId) != null) { _context.Update(loan); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } ViewBag.MovieId = new SelectList(_context.Movie, "Id", "Name", loan.MovieId); ViewBag.CustomerId = new SelectList(_context.Customer, "Id", "FirstName", loan.CustomerId); return(View(loan)); }