public async Task <IActionResult> Create([Bind("Did,Name,Gender")] Directors directors) { if (ModelState.IsValid) { _context.Add(directors); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(directors)); }
public async Task <IActionResult> Create([Bind("Cid,Name,Dob,Email,Phone")] Customers customers) { if (ModelState.IsValid) { _context.Add(customers); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(customers)); }
public async Task <IActionResult> Create([Bind("MovieId,Cid,DirectorId,Title,ReleaseYear")] Movies movies) { if (ModelState.IsValid) { _context.Add(movies); await _context.SaveChangesAsync(); 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> Create([Bind("MovieId,CustomerId,LoanDate,ReturnDate")] Loan loan) { if (ModelState.IsValid) { if (await _context.Loan.SingleOrDefaultAsync(l => l.CustomerId == loan.CustomerId && l.MovieId == loan.MovieId) == null) { _context.Add(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", "PersonalId", loan.CustomerId); return(View(loan)); }
public async Task <IActionResult> Edit([Bind("MovieId,Name,ReleaseDate,Producer,GenreId,Price")] Movie movieToEdit) { if (ModelState.IsValid) { if (_context.Movie.AsNoTracking().SingleOrDefault(x => x.MovieId == movieToEdit.MovieId) != null) { _context.Entry(movieToEdit).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } ViewBag.GenreId = new SelectList(_context.Genre, "GenreId", "Name", movieToEdit.GenreId); return(View(movieToEdit)); }
public async Task <IActionResult> Create([Bind("CustomerId,PersonalId,FirstName,FamilyName,Email,PhoneNumber,Address,Gender,Birthday")] Customer customer) { if (ModelState.IsValid) { if (await _context.Customer.SingleOrDefaultAsync(x => x.PersonalId == customer.PersonalId) == null) { _context.Add(customer); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } else { return(RedirectToAction(nameof(Index))); } } return(View(customer)); }
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 }); }