Esempio n. 1
0
        public async Task <ActionResult> RegisterBusiness(BusinessViewModel model, HttpPostedFileBase fileUpload, FormCollection collection)
        {
            FieldDatabaseDataService Fds = new FieldDatabaseDataService();

            List <field> fields = Fds.Read();

            ViewBag.Fields         = fields;
            ViewBag.ErrCheckFields = model.Fields;
            ViewBag.States         = DAL.DataSettings.US_STATES;

            if (IsValidCaptcha())
            {
                if (ModelState.IsValid)
                {
                    var user = new ApplicationUser {
                        UserName = model.Email, Email = model.Email
                    };
                    var result = await UserManager.CreateAsync(user, model.Password);

                    if (result.Succeeded)
                    {
                        try
                        {
                            UserManager.AddToRole(user.Id, "Business");
                            await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                            // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                            // Send an email with this link
                            // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                            // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                            // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                            if (fileUpload != null)
                            {
                                model.Photo = DAL.DatabaseHelper.UploadFile(DAL.DataSettings.BUSINESS_DIRECTORY, fileUpload, Server);
                            }
                            DAL.BusinessRepository br         = new DAL.BusinessRepository();
                            List <business>        businesses = br.SelectAll().ToList();

                            model.Approved = false;
                            model.Active   = true;
                            br.Insert(br.ToModel(model));

                            LoginViewModel loginModel = new LoginViewModel();
                            loginModel.Email = model.Email;

                            return(RedirectToAction("Index", "Home"));
                        }
                        catch (ArgumentException e)
                        {
                            ViewBag.Error = e.Message;
                            return(View());
                        }
                    }
                    AddErrors(result);
                }
            }
            // If we got this far, something failed, redisplay form
            return(View());
        }
Esempio n. 2
0
        // GET: Account/Create
        public ActionResult RegisterApplicant()
        {
            FieldDatabaseDataService Fds = new FieldDatabaseDataService();

            List <field> fields = Fds.Read();

            ViewBag.Fields = fields;

            return(View());
        }
Esempio n. 3
0
        public ActionResult RegisterBusiness()
        {
            FieldDatabaseDataService Fds = new FieldDatabaseDataService();

            List <field> fields = Fds.Read();

            ViewBag.Fields = fields;
            ViewBag.States = DAL.DataSettings.US_STATES;

            return(View());
        }