コード例 #1
0
        public ActionResult Create(Customer customer)
        {
            if (ModelState.IsValid)
            {
                customer.MembershipID = Guid.NewGuid();
                db.Customers.AddObject(customer);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MembershipID = new SelectList(db.aspnet_Membership, "UserId", "Password", customer.MembershipID);
            return View(customer);
        }
コード例 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Customers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToCustomers(Customer customer)
 {
     base.AddObject("Customers", customer);
 }
コード例 #3
0
 /// <summary>
 /// Create a new Customer object.
 /// </summary>
 /// <param name="firstName">Initial value of the FirstName property.</param>
 /// <param name="lastName">Initial value of the LastName property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="postCode">Initial value of the PostCode property.</param>
 /// <param name="telephoneNumber">Initial value of the TelephoneNumber property.</param>
 /// <param name="passportNumber">Initial value of the PassportNumber property.</param>
 /// <param name="membershipID">Initial value of the MembershipID property.</param>
 public static Customer CreateCustomer(global::System.String firstName, global::System.String lastName, global::System.String address, global::System.String postCode, global::System.Int32 telephoneNumber, global::System.Int32 passportNumber, global::System.Guid membershipID)
 {
     Customer customer = new Customer();
     customer.FirstName = firstName;
     customer.LastName = lastName;
     customer.Address = address;
     customer.PostCode = postCode;
     customer.TelephoneNumber = telephoneNumber;
     customer.PassportNumber = passportNumber;
     customer.MembershipID = membershipID;
     return customer;
 }
コード例 #4
0
 public ActionResult Edit(Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Customers.Attach(customer);
         db.ObjectStateManager.ChangeObjectState(customer, EntityState.Modified);
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MembershipID = new SelectList(db.aspnet_Membership, "UserId", "Password", customer.MembershipID);
     return View(customer);
 }
コード例 #5
0
        public ActionResult Register(RegisterModel model)
        {
            if (ModelState.IsValid)
            {
                Guid userKey = Guid.NewGuid();
                // Attempt to register the user
                MembershipCreateStatus createStatus;
                Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, userKey, out createStatus);

                if (createStatus == MembershipCreateStatus.Success)
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */);

                    // Attempt to create Customer
                    Customer c = new Customer();//model.FirstName, model.LastName, model.Address, model.PostCode, model.TelephoneNumber, model.PassportNumber, userKey);
                    c.FirstName = model.FirstName;
                    c.LastName = model.LastName;
                    c.Address = model.Address;
                    c.PostCode = model.PostCode;
                    c.TelephoneNumber = model.TelephoneNumber;
                    c.PassportNumber = model.PassportNumber;
                    c.MembershipID = userKey;
                    c.AddCustomer();

                    Cart cart = new Cart();
                    if(cart.isEmpty()){
                        return RedirectToAction("Index", "Home");
                    }
                    else{//customers was just shppping now
                        foreach (Booking b in cart.GetBookings())
                        {
                            b.customer_id = c.MembershipID;
                            return RedirectToAction("Payments", "Booking");
                        }
                    }
                }
                else
                {
                    ModelState.AddModelError("", ErrorCodeToString(createStatus));
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #6
0
 public ActionResult CustomerForm(Customer c)
 {
     c.MembershipID = Guid.NewGuid();
     System.Web.HttpContext.Current.Session["customer"] = c;
     return RedirectToAction("Hotels", "Home");
 }