public async Task <IActionResult> AccountCreate([Bind("Id,Email,Password,ConfirmPassword,FullName,Gender,Type")] Account account) { if (ModelState.IsValid) { _context.Add(account); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(account)); }
public async Task <IActionResult> Register(string email, string password, string fname, string lname, string ConfirmPassword, string gender) { if (_context.Account.FirstOrDefault(x => x.Email == email) != null) { ModelState.AddModelError("email", "Email address already exists. Please enter a different email address."); ViewData["Message"] = "User with this Email Already Exist"; return(View()); } Account account = new Account() { Email = email, Password = password, ConfirmPassword = ConfirmPassword, FullName = fname + " " + lname, Type = userType.Customer, Gender = gender }; var account_check = await _context.Account .FirstOrDefaultAsync(m => m.Email == account.Email); if (account_check != null) { return(NotFound()); } _context.Add(account); await _context.SaveChangesAsync(); await SignIn(account); return(RedirectToAction("Index", "Main")); }
public async Task <IActionResult> Create([Bind("Id,Count")] Cart cart) { if (ModelState.IsValid) { _context.Add(cart); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cart)); }
public async Task <IActionResult> Create([Bind("Id,OrderTime")] Click_Details click_Details) { if (ModelState.IsValid) { _context.Add(click_Details); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(click_Details)); }
public async Task <IActionResult> Create([Bind("ID,MechanicName,Adress")] Mechanic mechanic) { if (ModelState.IsValid) { _context.Add(mechanic); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(mechanic)); }
public async Task <IActionResult> Create([Bind("Id,Name,Price,Brand,Description,Category,ImageUrl")] Clothings product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("ID,Brand,Model,Price")] Car car) { try { if (ModelState.IsValid) { _context.Add(car); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } } catch (DbUpdateException /* ex*/) { ModelState.AddModelError("", "Unable to save changes. " + "Try again, and if the problem persists "); } return(View(car)); }