public ActionResult Register(string FirstName, string LastName, string Email, string Phone,
                                     string Street, string City, string State, string Password, string PostalCode)
        {
            var customer = new Customer
            {
                FirstName   = FirstName,
                LastName    = LastName,
                Email       = Email,
                PhoneNumber = Phone,
                Password    = Password
            };

            try
            {
                _customerManagementService.Enroll(customer);
                customer = _customerManagementService.GetCustomerByEmail(Email);
                _addressManagementService.AddNewAddress(new CustomerAddress {
                    Street = Street, City = City, State = State, CustomerID = customer.CustomerID, ZipCode = PostalCode
                });
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
            catch (Exception)
            {
                if (customer != null)
                {
                    _customerManagementService.RemoveCustomer(customer.Id.ToString());
                }
                return(Json(false, JsonRequestBehavior.AllowGet));
            }
        }
        public ActionResult Register(string firstname, string lastname, string email,
                                     string month, string year, string day, string password)
        {
            var dateofbirth = new DateTime();
            var dob         = month + "/" + day + "/" + year;

            DateTime.TryParse(dob, out dateofbirth);
            var customer = new Customer
            {
                FirstName = firstname,
                LastName  = lastname,
                Email     = email,
                Password  = password,
                DOB       = dateofbirth,
            };

            try
            {
                _customerManagementService.Enroll(customer);
                customer = _customerManagementService.GetCustomerByEmail(email);
                _addressManagementService.AddNewAddress(new CustomerAddress {
                    CustomerID = customer.Id
                });
                return(RedirectToAction("Home", "ContestIndex"));
            }
            catch (Exception)
            {
                if (customer != null)
                {
                    _customerManagementService.RemoveCustomer(customer.Id.ToString());
                }
                return(RedirectToAction("Index"));
            }
        }
        public async Task <ActionResult> Register(string firstname, string lastname, string email, string phone,
                                                  string gender, string dob, string accounttype, string password, string agreeToTos)
        {
            var dateofbirth = new DateTime();

            DateTime.TryParse(dob, out dateofbirth);
            var customer = new Customer
            {
                FirstName   = firstname,
                LastName    = lastname,
                Email       = email,
                PhoneNumber = phone,
                Password    = password,
                Gender      = gender,
                DOB         = dateofbirth,
                AccountType = accounttype,
                CreatedDate = DateTime.Now
            };

            try
            {
                if (String.IsNullOrEmpty(password) || String.IsNullOrEmpty(email) || String.IsNullOrEmpty(dob) ||
                    String.IsNullOrEmpty(firstname) || String.IsNullOrEmpty(agreeToTos))
                {
                    throw new Exception(ControllerConstants.missingRequiredFields);
                }
                bool emailIsInUse = await CheckIfEmailExists(email);

                if (emailIsInUse)
                {
                    throw new Exception(ControllerConstants.emailInUse);
                }
                _customerManagementService.Enroll(customer);
                customer = _customerManagementService.GetCustomerByEmail(email);
                _addressManagementService.AddNewAddress(new CustomerAddress {
                    CustomerID = customer.Id
                });
                MailAPI.SendWelcomeMessage(email, firstname);
                return(RedirectToAction("Index", "LogIn"));
            }
            catch (Exception ex)
            {
                if (customer != null)
                {
                    _customerManagementService.RemoveCustomer(customer.Id.ToString());
                }
                TempData["SignUpError"] = ex.Message;
                return(RedirectToAction("Index"));
            }
        }
        public ActionResult Register(WantedUser wantedUser, HttpPostedFileBase video)
        {
            Customer customer = null;

            try
            {
                bool emailIsInUse = _customerManagementService.CheckCustomerExist(wantedUser.Email);
                if (emailIsInUse)
                {
                    throw new Exception(ControllerConstants.emailInUse);
                }
                // Create New User
                customer = new Customer
                {
                    Email       = wantedUser.Email,
                    CreatedDate = DateTime.Now,
                    FirstName   = wantedUser.FirstName,
                    LastName    = wantedUser.LastName,
                    Gender      = wantedUser.Gender,
                    DOB         = wantedUser.DOB
                };
                _customerManagementService.Enroll(customer);
                customer = _customerManagementService.GetCustomerByEmail(wantedUser.Email);
                _addressManagementService.AddNewAddress(new CustomerAddress {
                    CustomerID = customer.Id
                });

                // Persist Wanted Data
                wantedUser.CustomerId            = customer.Id;
                wantedUser.EntryVideoFileName    = video.FileName;
                wantedUser.EntryVideoContentType = video.ContentType;

                using (var reader = new BinaryReader(video.InputStream))
                {
                    wantedUser.EntryVideo = reader.ReadBytes(video.ContentLength);
                }
                _wantedUserManagementService.Create(wantedUser);

                return(RedirectToAction("Subscribe", new { customerId = customer.Id.ToString() }));
            }
            catch (Exception ex)
            {
                if (customer != null)
                {
                    _customerManagementService.RemoveCustomer(customer.Id.ToString());
                }
                TempData["SignUpError"] = ex.Message;
                return(RedirectToAction("Register"));
            }
        }