public virtual async Task <IActionResult> ApplyVendorSubmit(ApplyVendorModel model, bool captchaValid, IFormFile uploadedFile)
        {
            if (!_vendorSettings.AllowCustomersToApplyForVendorAccount)
            {
                return(RedirectToRoute("HomePage"));
            }

            if (!await _groupService.IsRegistered(_workContext.CurrentCustomer))
            {
                return(Challenge());
            }

            //validate CAPTCHA
            if (_captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage && !captchaValid)
            {
                ModelState.AddModelError("", _captchaSettings.GetWrongCaptchaMessage(_translationService));
            }

            string pictureId   = string.Empty;
            string contentType = string.Empty;

            byte[] vendorPictureBinary = null;

            if (uploadedFile != null && !string.IsNullOrEmpty(uploadedFile.FileName))
            {
                try
                {
                    contentType = uploadedFile.ContentType;
                    if (string.IsNullOrEmpty(contentType))
                    {
                        ModelState.AddModelError("", "Empty content type");
                    }
                    else
                    if (!contentType.StartsWith("image"))
                    {
                        ModelState.AddModelError("", "Only image content type is allowed");
                    }

                    vendorPictureBinary = uploadedFile.GetPictureBits();
                }
                catch (Exception)
                {
                    ModelState.AddModelError("", _translationService.GetResource("Vendors.ApplyAccount.Picture.ErrorMessage"));
                }
            }

            if (ModelState.IsValid)
            {
                var description = FormatText.ConvertText(model.Description);
                var address     = new Address();
                //disabled by default
                var vendor = new Vendor
                {
                    Name        = model.Name,
                    Email       = model.Email,
                    Description = description,
                    PageSize    = 6,
                    AllowCustomersToSelectPageSize = true,
                    PageSizeOptions      = _vendorSettings.DefaultVendorPageSizeOptions,
                    AllowCustomerReviews = _vendorSettings.DefaultAllowCustomerReview,
                };
                model.Address.ToEntity(vendor.Address, true);
                if (vendorPictureBinary != null && !string.IsNullOrEmpty(contentType))
                {
                    var picture = await _pictureService.InsertPicture(vendorPictureBinary, contentType, null, reference : Reference.Vendor, objectId : vendor.Id);

                    if (picture != null)
                    {
                        vendor.PictureId = picture.Id;
                    }
                }

                await _vendorService.InsertVendor(vendor);

                //search engine name (the same as vendor name)
                var seName = await vendor.ValidateSeName(vendor.Name, vendor.Name, true, HttpContext.RequestServices.GetRequiredService <SeoSettings>(),
                                                         HttpContext.RequestServices.GetRequiredService <ISlugService>(), HttpContext.RequestServices.GetRequiredService <ILanguageService>());

                await _slugService.SaveSlug(vendor, seName, "");

                vendor.SeName = seName;
                await _vendorService.UpdateVendor(vendor);

                //associate to the current customer
                //but a store owner will have to manually acivate this vendor
                //if he wants to grant access to admin area
                _workContext.CurrentCustomer.VendorId = vendor.Id;
                await _customerService.UpdateCustomerField(_workContext.CurrentCustomer.Id, x => x.VendorId, _workContext.CurrentCustomer.VendorId);

                //notify store owner here (email)
                await _messageProviderService.SendNewVendorAccountApplyStoreOwnerMessage(_workContext.CurrentCustomer,
                                                                                         vendor, _workContext.CurrentStore, _languageSettings.DefaultAdminLanguageId);

                model.DisableFormInput = true;
                model.Result           = _translationService.GetResource("Vendors.ApplyAccount.Submitted");
                return(View(model));
            }

            //If we got this far, something failed, redisplay form
            model.DisplayCaptcha        = _captchaSettings.Enabled && _captchaSettings.ShowOnApplyVendorPage;
            model.TermsOfServiceEnabled = _vendorSettings.TermsOfServiceEnabled;
            model.TermsOfServicePopup   = _commonSettings.PopupForTermsOfServiceLinks;

            var countries = await _countryService.GetAllCountries(_workContext.WorkingLanguage.Id, _workContext.CurrentStore.Id);

            model.Address = await _mediator.Send(new GetVendorAddress()
            {
                Language                      = _workContext.WorkingLanguage,
                Address                       = null,
                Model                         = model.Address,
                ExcludeProperties             = false,
                PrePopulateWithCustomerFields = true,
                Customer                      = _workContext.CurrentCustomer,
                LoadCountries                 = () => countries,
            });

            return(View(model));
        }