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 IHttpActionResult Post(string email, int contestType, string comment)
        {
            var customer        = _customerManagementService.GetCustomerByEmail(email);
            var newCommentEntry = new CommentEntry();

            newCommentEntry.CommenterId   = customer.Id.ToString();
            newCommentEntry.ContestDate   = DateTime.Now;
            newCommentEntry.ContestType   = contestType;
            newCommentEntry.CommentString = comment;
            return(Ok());
        }
        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"));
            }
        }
        public IHttpActionResult Enter(string email, int contestType)
        {
            if (!HttpContext.Current.Request.Files.AllKeys.Any())
            {
                return(new StatusCodeResult(HttpStatusCode.InternalServerError, this));
            }

            var customer        = _customerManagementService.GetCustomerByEmail(email);
            var newContestEntry = new ContestEntry();
            var file            = HttpContext.Current.Request.Files[""];

            newContestEntry.ImageBytes = new byte[file.ContentLength];
            file.InputStream.Read(newContestEntry.ImageBytes, 0, file.ContentLength);
            newContestEntry.ContestantId = customer.Id.ToString();
            newContestEntry.ContestDate  = DateTime.Now;
            newContestEntry.ContestType  = contestType;
            return(Ok());
        }