Пример #1
0
        public ActionResult Create(BusinessLayer.CustomerDetail values)
        {
            if (ModelState.IsValid)
            {
                // try
                //{ Check if this new email already exists on DB
                if (!dbset.ConfirmEmailIsUnique(values.Email.ToString()))
                {
                    var order  = new BusinessLayer.CustomerDetail();
                    var cartid = sc.GetCartId(this.HttpContext);

                    //Create new member into the database
                    sc.CreateMember(values);//customerDetail

                    //send admin an email to call and confirm new user
                    BusinessLayer.SendEmails sendmail = new SendEmails();
                    sendmail.NewCustomerEmail(values);


                    //Update tblUserProfile with correct UserName
                    sc.UpdatetblUserProfileWithCurrentUserName(values.Email.Trim(), cartid);

                    return(RedirectToAction("Index", "ShoppingCart"));
                }
                else
                {
                    ViewBag.StateId = new SelectList(dbset.States, "StateId", "StateName");
                    return(View("NotUniqueEmailIndex"));
                }
            }
            ViewBag.StateId = new SelectList(dbset.States, "StateId", "StateName");

            return(View());
        }
Пример #2
0
        public void CreateMember(CustomerDetail customer)
        {
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("spAddMemberToCustomerDB", con);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter paramUsername = new SqlParameter();
                paramUsername.ParameterName = "@Username";
                paramUsername.Value         = customer.Email;
                cmd.Parameters.Add(paramUsername);

                SqlParameter parampassword = new SqlParameter();
                parampassword.ParameterName = "@password";
                parampassword.Value         = customer.password;
                cmd.Parameters.Add(parampassword);

                SqlParameter paramFirstName = new SqlParameter();
                paramFirstName.ParameterName = "@FirstName";
                paramFirstName.Value         = customer.FirstName;
                cmd.Parameters.Add(paramFirstName);

                SqlParameter paramLastName = new SqlParameter();
                paramLastName.ParameterName = "@LastName";
                paramLastName.Value         = customer.LastName;
                cmd.Parameters.Add(paramLastName);

                SqlParameter paramAddress = new SqlParameter();
                paramAddress.ParameterName = "@Address";
                paramAddress.Value         = customer.Address;
                cmd.Parameters.Add(paramAddress);

                SqlParameter paramStateId = new SqlParameter();
                paramStateId.ParameterName = "@StateId";
                paramStateId.Value         = customer.StateId;
                cmd.Parameters.Add(paramStateId);

                SqlParameter paramPhone = new SqlParameter();
                paramPhone.ParameterName = "@Phone";
                paramPhone.Value         = customer.Phone;
                cmd.Parameters.Add(paramPhone);

                SqlParameter paramEmail = new SqlParameter();
                paramEmail.ParameterName = "@Email";
                paramEmail.Value         = customer.Email;
                cmd.Parameters.Add(paramEmail);
                con.Open();
                cmd.ExecuteNonQuery();
            }
        }
Пример #3
0
        public ActionResult Edit(BusinessLayer.CustomerDetail cusdet)
        {
            if (ModelState.IsValid)
            {
                dbset.SaveChangesCustomerDetailToDB(cusdet);

                return(RedirectToAction("Index", "Home"));
            }
            var    cartid   = sc.GetCartId(this.HttpContext);
            string UserName = sc.GetLoginDetail(cartid);

            BusinessLayer.CustomerDetail fooditem = dbset.CustomerDetails.Single(emp => emp.Email == UserName);

            ViewBag.StateId = new SelectList(dbset.States.OrderBy(x => x.StateName), "StateId", "StateName", fooditem.StateId);
            return(View(fooditem));
        }
        public void SaveChangesCustomerDetailToDB(CustomerDetail employee)
        {
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                SqlCommand cmd = new SqlCommand("spSaveChangesCustomerDetail", con);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter parampassword = new SqlParameter();
                parampassword.ParameterName = "@password";
                parampassword.Value         = employee.password;
                cmd.Parameters.Add(parampassword);

                SqlParameter paramFirstName = new SqlParameter();
                paramFirstName.ParameterName = "@FirstName";
                paramFirstName.Value         = employee.FirstName;
                cmd.Parameters.Add(paramFirstName);

                SqlParameter paramLastName = new SqlParameter();
                paramLastName.ParameterName = "@LastName";
                paramLastName.Value         = employee.LastName;
                cmd.Parameters.Add(paramLastName);

                SqlParameter paramAddress = new SqlParameter();
                paramAddress.ParameterName = "@Address";
                paramAddress.Value         = employee.Address;
                cmd.Parameters.Add(paramAddress);

                SqlParameter paramStateId = new SqlParameter();
                paramStateId.ParameterName = "@StateId";
                paramStateId.Value         = employee.StateId;
                cmd.Parameters.Add(paramStateId);

                SqlParameter paramPhone = new SqlParameter();
                paramPhone.ParameterName = "@Phone";
                paramPhone.Value         = employee.Phone;
                cmd.Parameters.Add(paramPhone);

                SqlParameter paramEmail = new SqlParameter();
                paramEmail.ParameterName = "@Email";
                paramEmail.Value         = employee.Email;
                cmd.Parameters.Add(paramEmail);


                con.Open();
                cmd.ExecuteNonQuery();
            }
        }
Пример #5
0
        //
        // GET: /CheckOut/Edit/5

        public ActionResult Edit()
        {
            var    cartid   = sc.GetCartId(this.HttpContext);
            string UserName = sc.GetLoginDetail(cartid);

            if (UserName == "Guest")
            {
                return(View("Index"));
            }
            else
            {
                BusinessLayer.CustomerDetail fooditem = dbset.CustomerDetails.Single(emp => emp.Email == UserName);
                if (fooditem == null)
                {
                    return(HttpNotFound());
                }
                ViewBag.StateId = new SelectList(dbset.States.OrderBy(x => x.StateName), "StateId", "StateName", fooditem.StateId);
                return(View(fooditem));
            }
        }