public ActionResult Create([Bind(Include = "id,Username,Email,Password,FirstName,LastName,Street,Town,City,PhoneNumber,IsMagician,IsClown,IsBalloonAnimals,IsPettingZoo,IsCakes,IsCatering,IsFacePainting,IsJuggling,IsDJ,IsPartyGames,IsBouncyCastle,IsPuppets,IsHennaTattoos,IsHairBraiding,IsOther, CustomerId")] Entertainer entertainer) { if (ModelState.IsValid) { Customer cust = new Customer(); cust.City = entertainer.City; cust.Email = entertainer.Email; cust.FirstName = entertainer.FirstName; cust.LastName = entertainer.LastName; cust.Username = entertainer.Username; cust.Password = entertainer.Password; cust.Street = entertainer.Street; cust.Town = entertainer.Town; cust.PhoneNumber = entertainer.PhoneNumber; db.Customer.Add(cust); db.SaveChanges(); entertainer.CustomerId = cust.id; db.Entertainer.Add(entertainer); db.SaveChanges(); return RedirectToAction("Index"); } return View(entertainer); }
public ActionResult Login(Customer customer, string returnUrl) { using (ApplicationDbContext db = new ApplicationDbContext()) { try { var cust = db.Customers.Single(e => e.Email == customer.Email && e.Password == customer.Password); if (cust != null) { Session["id"] = cust.id.ToString(); Session["FirstName"] = cust.FirstName.ToString(); /* var ents = db.Entertainers.ToArray(); var numOfEnts = ents.Count(); for(int i=0; i < numOfEnts; i++) { if( ents[numOfEnts].CustomerId == cust.id) { return RedirectToAction("Index", "Enterainer"); } } */ return RedirectToAction("Index"); } } catch { ModelState.AddModelError("", "Username or Password is Incorrect!"); } } // If we got this far, something failed, redisplay form return View(); }