public ActionResult Create([Bind(Include = "Id,FirstName,LastName,Address,City,StateId,ZipCode,PreferenceId,PaymentId,Gifting,Donating,AccountStatus,MemberSince,UserId")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                customer.UserId      = userId;
                customer.MemberSince = DateTime.Now;
                customer.Donating    = false;
                if (Geocode.CheckValidAddress(customer))
                {
                    if (Geocode.isValidLocation)
                    {
                        db.Customers.Add(customer);
                        db.SaveChanges();
                        return(RedirectToAction("Index", "Dashboard"));
                    }
                }
                return(RedirectToAction("Create", new { customer.PreferenceId, isValid = false, firstName = customer.FirstName, lastName = customer.LastName }));
            }

            //ViewBag.PaymentId = new SelectList(db.Payments, "Id", "Id", customer.PaymentId);
            ViewBag.PreferenceId = new SelectList(db.Preferences, "Id", "OptimalSize", customer.PreferenceId);
            ViewBag.StateId      = new SelectList(db.States, "Id", "Name", customer.StateId);
            return(View(customer));
        }
 public ActionResult PersonalUpdate(DashboardViewModel dashboardViewModel)
 {
     if (Geocode.CheckValidAddress(dashboardViewModel.Customer))
     {
         if (Geocode.isValidLocation)
         {
             db.Entry(dashboardViewModel.Customer).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Main", "Dashboard"));
         }
     }
     return(RedirectToAction("PersonalUpdate", new { isValid = false }));
 }
        public ActionResult CreateAccount(RegistrationViewModel registrationViewModel)
        {
            var userId = GetId();

            if (Geocode.CheckValidAddress(registrationViewModel.Customer))
            {
                if (Geocode.isValidLocation)
                {
                    registrationViewModel.Customer.UserId        = userId;
                    registrationViewModel.Customer.MemberSince   = DateTime.Now;
                    registrationViewModel.Customer.Donating      = false;
                    registrationViewModel.Customer.AccountStatus = false;
                    registrationViewModel.Customer.PreferenceId  = registrationViewModel.Preference.Id;
                    db.Customers.Add(registrationViewModel.Customer);
                    db.SaveChanges();
                    Customer customerForEmail = db.Customers.Include(c => c.State).Where(c => c.UserId == userId).Single();
                    SendEmail.Main(customerForEmail);
                    return(RedirectToAction("Main", "Dashboard"));
                }
            }
            return(RedirectToAction("CreateAccount", new { ValidAddress = false }));
        }