示例#1
0
        public void CreateAPartnerAccountWithAnAlreadyUsedUsername()
        {
            PartnerBLL partnerBLL = new PartnerBLL(TestApp.Connector);
            CountryDTO country    = new CountryDTO()
            {
                Id = "PE"
            };
            DistrictDTO district = new DistrictDTO()
            {
                Country  = country,
                Code     = "150106",
                Province = new ProvinceDTO()
                {
                    Country = country,
                    Code    = "150100",
                    Region  = new RegionDTO()
                    {
                        Country = country,
                        Code    = "150000"
                    }
                }
            };
            PartnerDTO partner = new PartnerDTO()
            {
                Username   = "******",
                Password   = new byte[64],
                FirstName  = "Aldo",
                MiddleName = "Alejandro",
                LastName   = "Astupillo Cáceres",
                Gender     = new GenderDTO()
                {
                    Id = "M"
                },
                EmailAddress      = "*****@*****.**",
                MobileNumber      = "+51989637468",
                CompanyName       = "Hatun Search",
                Address           = "Av. Larco 322",
                Country           = country,
                District          = district,
                PhoneNumber       = "+5115474849",
                Website           = "https://hatunsearch.me",
                PreferredCurrency = new CurrencyDTO()
                {
                    Id = "PEN"
                },
                PreferredLanguage = new LanguageDTO()
                {
                    Id = "ES"
                }
            };

            PartnerBLL.SignupResult result = partnerBLL.Signup(partner, "https://partners.hatunsearch.me", "https://partners.hatunsearch.me/es-pe/accounts/signup/verification");
            Assert.AreEqual(PartnerBLL.SignupResult.UsernameAlreadyUsed, result);
        }
示例#2
0
        public ActionResult SignupStep4(PartnerPreferencesDTO preferences)
        {
            if (ModelState.IsValid)
            {
                PartnerBLL partnerBLL = new PartnerBLL(WebApp.Connector)
                {
                    EmailAddressVerificationSubject  = LocalizationProvider["VerifyYourEmailAddress"],
                    EmailAddressVerificationTemplate = LocalizationProvider["EmailVerificationTemplate"]
                };
                PartnerDTO             partner      = new PartnerDTO();
                PartnerCredentialDTO   credential   = Session["Signup$Credential"] as PartnerCredentialDTO;
                PartnerPersonalInfoDTO personalInfo = Session["Signup$PersonalInfo"] as PartnerPersonalInfoDTO;
                PartnerCompanyInfoDTO  companyInfo  = Session["Signup$CompanyInfo"] as PartnerCompanyInfoDTO;
                partner.Join(credential);
                partner.Join(personalInfo);
                partner.Join(companyInfo);
                partner.Join(preferences);
                Uri    requestUrl = Request.Url;
                string baseUrl    = new UriBuilder(requestUrl.Scheme, requestUrl.Host, requestUrl.Port).ToString();
                PartnerBLL.SignupResult result = partnerBLL.Signup(partner, baseUrl, Url.Action("VerifyEmailAddress"));
                switch (result)
                {
                case PartnerBLL.SignupResult.OK:
                    Session["Signup$Preferences"] = preferences;
                    return(RedirectToAction("VerifyEmailAddress"));

                case PartnerBLL.SignupResult.UsernameAlreadyUsed:
                    TempData["Errors"] = new Dictionary <string, string>()
                    {
                        { "Username", result.ToString() }
                    };
                    return(RedirectToAction("SignupStep1"));

                case PartnerBLL.SignupResult.EmailAddressAlreadyUsed:
                    TempData["Errors"] = new Dictionary <string, string>()
                    {
                        { "EmailAddress", result.ToString() }
                    };
                    return(RedirectToAction("SignupStep2"));

                default: return(BadRequest());
                }
            }
            else
            {
                return(BadRequestWithErrors(preferences));
            }
        }