示例#1
0
        // GET: Countrie/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            CountryInformation item  = null;
            CountryViewModel   model = new CountryViewModel();

            try
            {
                item                = db.countryInformations.Single(s => s.Id == id);
                model.Id            = item.Country.Id;
                model.Name          = item.Country.Name;
                model.imagePath     = item.Country.imagePath;
                model.isActive      = item.Country.isActive;
                model.State         = item.State;
                model.Addressheader = item.Addressheader;
                model.AddressLine1  = item.AddressLine1;
                model.AddressLine2  = item.AddressLine2;
                model.ZIPcode       = item.ZIPcode;
                model.City          = item.City;
                model.IDNumber      = item.IDNumber;
                model.PhoneNumber   = item.PhoneNumber;
                model.Semt          = item.Semt;
                model.Ilce          = item.Ilce;
                model.TaxIDNumber   = item.TaxIDNumber;
                model.Area          = item.Area;
            }
            catch (Exception)
            {
                model = null;
            }
            return(PartialView(model));
        }
示例#2
0
        public long AddNewCountry(CountryInformation countryInformation)
        {
            var returnValue = (long)0;
            var stopwatch   = new Stopwatch();

            stopwatch.Start();
            try
            {
                var newCountry = new countries
                {
                    ISO2            = countryInformation.ISO2,
                    CountryName     = countryInformation.Name,
                    LongCountryName = countryInformation.LongCountryName,
                    ISO3            = countryInformation.ISO3,
                    NumCode         = countryInformation.NumCode,
                    UNMemberState   = countryInformation.UNMemberState,
                    CallingCode     = countryInformation.CallingCode,
                    CCTLD           = countryInformation.CCTLD
                };
                _transshipEntities.countries.Add(newCountry);
                _transshipEntities.SaveChanges();
                returnValue = newCountry.CountryID;
            }
            catch (Exception e)
            {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
            }
            finally
            {
                stopwatch.Stop();
            }
            return(returnValue);
        }
示例#3
0
        public long UpdateCountry(CountryInformation countryInformation)
        {
            var returnValue = (long)0;
            var stopwatch   = new Stopwatch();

            stopwatch.Start();
            try
            {
                var userEntity = _transshipEntities.countries.First(x => x.CountryID == countryInformation.Id);
                userEntity.ISO2            = countryInformation.ISO2;
                userEntity.CountryName     = countryInformation.Name;
                userEntity.LongCountryName = countryInformation.LongCountryName;
                userEntity.ISO3            = countryInformation.ISO3;
                userEntity.NumCode         = countryInformation.NumCode;
                userEntity.UNMemberState   = countryInformation.UNMemberState;
                userEntity.CallingCode     = countryInformation.CallingCode;
                userEntity.CCTLD           = countryInformation.CCTLD;
                _transshipEntities.SaveChanges();
                returnValue = userEntity.CountryID;
            }
            catch (Exception e)
            {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
            }
            finally
            {
                stopwatch.Stop();
            }
            return(returnValue);
        }
示例#4
0
    public FeatureManager(GeolocatedFeatureType feature)
    {
        string ip = Member.GetCurrentIP(HttpContext.Current.Request);
        var    ci = new CountryInformation(ip);

        this.CC      = ci.CountryCode;
        this.Feature = feature;
    }
        public long AddCountry(CountryInformation information)
        {
            LogBook.LogBook.TextLog.Info(string.Format("Country Name {0}", information.Name));
            LogBook.LogBook.TextLog.Info(string.Format("Long Country Name {0}", information.LongCountryName));
            var repository = new INSecurityImplementation();
            var result     = repository.AddNewCountry(information);

            return(result >= 1 ? (long)1 : (long)0);
        }
示例#6
0
 private void FillInCountry(Country country, City city, Region region, CountryInformation countryFromAPI)
 {
     country.Title      = countryFromAPI.Title;
     country.Code       = countryFromAPI.Code;
     country.CapitalId  = city.Id;
     country.Area       = (double)countryFromAPI.Area;
     country.Population = (int)countryFromAPI.Population;
     country.RegionId   = region.Id;
 }
        public long EraseCountry(CountryInformation userInformation)
        {
            LogBook.LogBook.TextLog.Info(string.Format("Request {0}", Request.RequestUri.GetLeftPart(UriPartial.Authority)));
            LogBook.LogBook.TextLog.Info(string.Format("User Id {0}", userInformation.Id));
            var repository = new INSecurityImplementation();
            var result     = repository.EraseCountry(userInformation);

            return(result >= 1 ? (long)1 : (long)0);
        }
示例#8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            AddLang();


            int publishersWebsiteId;
            isAuthorized = Request.UrlReferrer != null && Request.UrlReferrer.Host != Request.Url.Host && Request.QueryString[GlobalPostback.Parameters.SubId] != null &&
                           int.TryParse(Request.QueryString[GlobalPostback.Parameters.PublishersWebsiteId], out publishersWebsiteId);
            //isAuthorized = true;
            if (!isAuthorized)
            {
                HandleUnauthorizedRequest();
                return;
            }

            PublishersWebsiteId = Convert.ToInt32(Request.QueryString[GlobalPostback.Parameters.PublishersWebsiteId]);
            ExternalUserName    = Request.QueryString[GlobalPostback.Parameters.SubId];
            SubId2      = Request.QueryString[GlobalPostback.Parameters.SubId2];
            SubId3      = Request.QueryString[GlobalPostback.Parameters.SubId3];
            Age         = Request.QueryString[GlobalPostback.Parameters.Age] ?? "Unknown";
            CountryCode = new CountryInformation(IP.Current).CountryCode;

            var host = Request.UrlReferrer.Host;
            //host = "usetitan.com";
            ptcOfferWallManager = new PTCOfferWallManager(host,
                                                          CountryCode,
                                                          ExternalUserName,
                                                          PublishersWebsiteId,
                                                          Request.Browser.IsMobileDevice,
                                                          Age,
                                                          Request.QueryString[GlobalPostback.Parameters.Gender]);

            if (ptcOfferWallManager.PublishersWebsite == null)
            {
                ErrorLogger.Log(string.Format("Requested Ptc Offerwall on website that has not been accepted ({0})", Request.UrlReferrer.Host), LogType.Publisher);
                HandleUnauthorizedRequest();
                return;
            }

            Session["PtcOfferWallManager"] = ptcOfferWallManager;

            Gender = ptcOfferWallManager.Gender.ToString();
            LoadOfferWalls();
        }
    }
示例#9
0
        private void buttonGetInf_Click(object sender, EventArgs e)
        {
            if (textBoxCountryName.Text != null)
            {
                countryFromAPI = apiConnecterCI.GetCountryInformation(textBoxCountryName.Text);

                if (countryFromAPI != null)
                {
                    FillFormFields();
                    AddCountryToDatabase();
                }
                else
                {
                    MessageBox.Show("Country information not found!");
                }
            }
        }
示例#10
0
        public ActionResult Edit(CountryViewModel model)
        {
            if (ModelState.IsValid)
            {
                CountryInformation info = null;
                try
                {
                    info = db.countryInformations.Single(s => s.Id == model.Id);
                }
                catch (Exception)
                {
                    ViewBag.AlertMessage = "Something gone wrong. Try again please!";
                    return(RedirectToAction("List"));
                }
                info.IDNumber         = model.IDNumber;
                info.State            = model.State;
                info.Addressheader    = model.Addressheader;
                info.AddressLine1     = model.AddressLine1;
                info.AddressLine2     = model.AddressLine2;
                info.ZIPcode          = model.ZIPcode;
                info.City             = model.City;
                info.PhoneNumber      = model.PhoneNumber;
                info.Semt             = model.Semt;
                info.Ilce             = model.Ilce;
                info.TaxIDNumber      = model.TaxIDNumber;
                info.Area             = model.Area;
                info.Country.Name     = model.Name;
                info.Country.isActive = model.isActive;
                if (model.File != null && model.File.ContentLength > 0)
                {
                    var fileExtension = Path.GetExtension(model.File.FileName);
                    var fileName      = Path.GetFileNameWithoutExtension(model.File.FileName) + "-" +
                                        DateTime.Now.ToString("yyyyMMddHHmmssfff") + fileExtension;
                    var path = Path.Combine(Server.MapPath("~/Img/country"), fileName);
                    model.File.SaveAs(path);
                    info.Country.imagePath = "/Img/country/" + fileName;
                }

                db.SaveChanges();
                TempData["AlertMessage"] = "informations of country " + "\"" + info.Country.Name + "\"" + " has succesfully changed";
                return(RedirectToAction("List"));
            }
            TempData["AlertMessage"] = "Something gone wrong. Try again please!";
            return(RedirectToAction("List"));
        }
        public CountryInformation GetCountryInformation(string countryName)
        {
            string countryResponse = Task.Run(() => GetCountryInformationAsynk(countryName)).Result;

            if (countryResponse != null)
            {
                try
                {
                    countryFromAPI = JsonConvert.DeserializeObject <List <CountryInformation> >(countryResponse)[0];
                }
                catch (Exception)
                {
                    return(null);
                }
            }

            return(countryFromAPI);
        }
示例#12
0
        public ActionResult DeleteConfirmed(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Country            country = db.countries.Find(id);
            CountryInformation info    = db.countryInformations.Find(id);

            if (country == null)
            {
                return(HttpNotFound());
            }

            db.countryInformations.Remove(info);
            db.countries.Remove(country);
            db.SaveChanges();
            return(RedirectToAction("List"));
        }
示例#13
0
        public string AddCountryInformation(CountryInformation countryFromAPI)
        {
            city = GetCity(countryFromAPI);

            if (city == null)
            {
                return("City not found!");
            }

            region = GetRegion(countryFromAPI);

            if (region == null)
            {
                return("Region not found!");
            }

            string message = AddCountry(city, region, countryFromAPI);

            return(message);
        }
示例#14
0
    private static void TrySetRepresentativeAsReferer(Member NewMember, CountryInformation CIService)
    {
        if (AppSettings.Representatives.Policy == AppSettings.Representatives.RepresentativesPolicy.Automatic)
        {
            List <Representative> representatives = Representative.GetAllActiveFromCountry(CIService.CountryName);

            if (representatives.Count > 0)
            {
                Random         random         = new Random();
                Representative representative = representatives[random.Next(representatives.Count)];

                if (NewMember.ReferrerId == -1)
                {
                    NewMember.ReferrerId = representative.UserId;
                }

                NewMember.RepresentativeId = representative.UserId;
            }
        }
    }
示例#15
0
        public ActionResult Create(string name)
        {
            if (String.IsNullOrWhiteSpace(name))
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Country country = new Country {
                Name = name
            };

            db.countries.Add(country);
            db.SaveChanges();

            CountryInformation info = new CountryInformation {
                Id = db.countries.First(f => f.Name == name).Id
            };

            db.countryInformations.Add(info);
            db.SaveChanges();
            TempData["AlertMessage"] = "country " + "\"" + country.Name + "\"" + " has succesfully created";
            return(RedirectToAction("List"));
        }
示例#16
0
        private Region GetRegion(CountryInformation countryFromAPI)
        {
            region = Task.Run(() => GetRegionAsynk(countryFromAPI.Region)).Result;

            if (region == null)
            {
                region       = new Region();
                region.Title = countryFromAPI.Region;

                try
                {
                    Task.Run(() => CreateRegionAsynk(region)).Wait();
                }
                catch (Exception)
                {
                    return(null);
                }

                region = Task.Run(() => GetRegionAsynk(countryFromAPI.Region)).Result;
            }

            return(region);
        }
示例#17
0
        private City GetCity(CountryInformation countryFromAPI)
        {
            city = Task.Run(() => GetCityAsynk(countryFromAPI.Capital)).Result;

            if (city == null)
            {
                city       = new City();
                city.Title = countryFromAPI.Capital;

                try
                {
                    Task.Run(() => CreateCityAsynk(city)).Wait();
                }
                catch (Exception)
                {
                    return(null);
                }

                city = Task.Run(() => GetCityAsynk(countryFromAPI.Capital)).Result;
            }

            return(city);
        }
示例#18
0
        public decimal EraseCountry(CountryInformation userInformation)
        {
            var returnValue = (decimal)0;
            var stopwatch   = new Stopwatch();

            stopwatch.Start();
            try
            {
                var userEntity = _transshipEntities.countries.First(x => x.CountryID == userInformation.Id);
                _transshipEntities.countries.Remove(userEntity);
                _transshipEntities.SaveChanges();
                returnValue = 1000;
            }
            catch (Exception e)
            {
                LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty));
            }
            finally
            {
                stopwatch.Stop();
            }
            return(returnValue);
        }
示例#19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int _publishersWebsiteId;

        bool IsPreview = Request.UrlReferrer != null && Request.Url.Host == new Uri(AppSettings.Site.Url).Host;

        isAuthorized = Request.UrlReferrer != null &&
                       (Request.UrlReferrer.Host != Request.Url.Host ||
                        IsPreview) &&
                       Request.QueryString[GlobalPostback.Parameters.SubId] != null &&
                       int.TryParse(Request.QueryString[GlobalPostback.Parameters.PublishersWebsiteId], out _publishersWebsiteId);

        if (!isAuthorized)
        {
            HandleUnauthorizedRequest();
            return;
        }

        PemissionErrorPlaceHolder.Visible = false;
        OffersPlaceHolder.Visible         = true;

        publishersWebsiteId = Convert.ToInt32(Request.QueryString[GlobalPostback.Parameters.PublishersWebsiteId]);
        externalUserName    = Request.QueryString[GlobalPostback.Parameters.SubId];
        subId2      = Request.QueryString[GlobalPostback.Parameters.SubId2];
        subId3      = Request.QueryString[GlobalPostback.Parameters.SubId3];
        countryCode = new CountryInformation(IP.Current).CountryCode;

        externalOfferWallsManager = new ExternalOfferWallsManager(Request.UrlReferrer.Host, publishersWebsiteId, countryCode, IsPreview);

        if (externalOfferWallsManager.PublishersWebsite == null)
        {
            ErrorLogger.Log(string.Format("Requested Offers on website that has not been accepted ({0})", Request.UrlReferrer.Host), LogType.Publisher);
            HandleUnauthorizedRequest();
            return;
        }
        LoadOffers();
    }
示例#20
0
        private string AddCountry(City city, Region region, CountryInformation countryFromAPI)
        {
            country = Task.Run(() => GetCountryAsynk(countryFromAPI.Code)).Result;

            if (country == null)
            {
                country = new Country();
                FillInCountry(country, city, region, countryFromAPI);

                try
                {
                    Task.Run(() => CreateCountryAsynk(country)).Wait();
                }
                catch (Exception)
                {
                    return("Unable to create Country!");
                }

                return("New country added.");
            }
            else
            {
                FillInCountry(country, city, region, countryFromAPI);

                try
                {
                    Task.Run(() => UpdateCountryAsync(country)).Wait();
                }
                catch (Exception)
                {
                    return("Unable to update Country!");
                }

                return("Country updated.");
            }
        }
示例#21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GlobalMasterHelper.PageLoad();
        AdBlockManager.CheckDenyForAll();

        RegistrationCaptchaPlaceHolder.Visible = AppSettings.Registration.IsRegistrationCaptchaEnabled;
        PINSectionPlaceHolder.Visible          = AppSettings.Registration.IsPINEnabled;

        if (!Page.IsPostBack)
        {
            AppSettings.Authentication.Reload();

            if (Request.QueryString["e"] != null)
            {
                Email.Text = Request.QueryString["e"];
            }

            if (TitanFeatures.IsRetireYoung)
            {
                ReferrerUtils.SetReferrer("RetireYoung");
            }

            if (Request.QueryString["u"] != null || ReferrerUtils.GetReferrerName() != null)
            {
                string refUsername;
                if (Request.QueryString["u"] != null)
                {
                    ReferrerUtils.SetReferrer(Request.QueryString["u"]);
                }

                refUsername = ReferrerUtils.GetReferrerName();

                if (!Page.IsPostBack)
                {
                    PoolRotatorManager.TryAddLinkView(refUsername);
                }

                // With referral link for Pool Rotator
                refUsername = PoolRotatorManager.TryGetUserNameFromPool(refUsername);

                Referer.Text = refUsername;
            }
            else if (Session["PaidToPromoteReferer"] != null)
            {
                var refId       = Convert.ToInt32(Session["PaidToPromoteReferer"].ToString());
                var refUsername = new Member(refId).Name;

                Referer.Text = refUsername;
            }
        }
        FeatureManager Manager = null;

        //Facebook OAuth
        if (IsFromFacebookOAuth)
        {
            //Check if country is eligible for Facebook Register
            Manager = new FeatureManager(GeolocatedFeatureType.FacebookRegistration);

            //Hide unnecessary fields
            FacebookMember fbMember = new FacebookMember(Session["accessToken"].ToString());

            Email.Text = fbMember.Email;

            //Passwords validators
            RegularExpressionValidator2.Enabled = false;
            PasswordRequired.Enabled            = false;
            ConfirmPasswordRequired.Enabled     = false;
            PasswordCompare.Enabled             = false;
            CustomValidator1.Enabled            = false;
            TitanCaptcha.Visible = false;

            FirstName.Text  = fbMember.FirstName;
            SecondName.Text = fbMember.LastName;
        }
        else
        {
            //Check if country is eligible for Standard Register
            Manager = new FeatureManager(GeolocatedFeatureType.Registration);
        }

        if (!Manager.IsAllowed)
        {
            RegistrationPanel.Visible = false;
            CreateUserButton.Visible  = false;
            ErrorMessagePanel.Visible = true;
            ErrorMessage.Text         = U4000.SORRYCOUNTRY;
        }

        //Set up textbox hints
        HintAdder.Add(Username, L1.REG_USERNAME);
        HintAdder.Add(Password, U3501.REG_PASSWORD);
        HintAdder.Add(Email, L1.REG_EMAIL);
        HintAdder.Add(PIN, L1.REG_PIN);
        HintAdder.Add(Referer, L1.REG_REFERER);

        Username.Attributes.Add("placeholder", L1.USERNAME);
        Email.Attributes.Add("placeholder", "Email");
        Password.Attributes.Add("placeholder", L1.PASSWORD);
        ConfirmPassword.Attributes.Add("placeholder", L1.CONFIRMPASSWORD);
        PIN.Attributes.Add("placeholder", L1.DESIREDPIN);
        BirthYear.Attributes.Add("placeholder", L1.BIRTHYEAR);
        FirstName.Attributes.Add("placeholder", L1.FIRSTNAME);
        SecondName.Attributes.Add("placeholder", L1.SECONDNAME);
        City.Attributes.Add("placeholder", L1.CITY);
        StateProvince.Attributes.Add("placeholder", L1.STATEPROVINCE);
        ZipCode.Attributes.Add("placeholder", L1.ZIPCODE);

        Address.Attributes.Add("placeholder", L1.ADDRESS);

        //Add translations
        LangAdder.Add(CreateUserButton, L1.REGISTER);
        LangAdder.Add(RegularExpressionValidator1, L1.ER_INVALIDUSERNAME, true);
        LangAdder.Add(UserNameRequired, L1.REG_REQ_USERNAME, true);
        LangAdder.Add(EmailRequired, L1.REG_REQ_EMAIL, true);
        LangAdder.Add(CorrectEmailRequired, L1.ER_BADEMAILFORMAT, true);
        LangAdder.Add(PasswordRequired, L1.REG_REQ_PASS, true);
        LangAdder.Add(RegularExpressionValidator2, L1.ER_INVALIDPASS, true);
        LangAdder.Add(PasswordCompare, L1.ER_PASSDIFFER, true);
        LangAdder.Add(ConfirmPasswordRequired, L1.REG_REQ_CONFIRM, true);
        LangAdder.Add(RegularExpressionValidator3, L1.ER_BADPIN, true);
        LangAdder.Add(RequiredFieldValidator2, L1.REG_REQ_PIN, true);
        LangAdder.Add(RegularExpressionValidator4, L1.ER_BADYEAR, true);
        LangAdder.Add(RequiredFieldValidator1, L1.REG_REQ_YEAR, true);
        LangAdder.Add(RefererValidator, L1.ER_BADREF, true);
        LangAdder.Add(CustomValidator1, L1.ER_BADCAPTCHA, true);
        LangAdder.Add(CustomValidator4, L1.REG_REQ_TOS, true);

        EarnerCheckBox.Text     = U6000.EARNER;
        AdvertiserCheckBox.Text = L1.ADVERTISER;
        PublisherCheckBox.Text  = U6000.PUBLISHER;

        //Detailed info
        LangAdder.Add(RE_1, L1.DETAILEDNOSPECIAL + " " + L1.FIRSTNAME, true);
        LangAdder.Add(RF_1, L1.FIRSTNAME + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_2, L1.DETAILEDNOSPECIAL + " " + L1.SECONDNAME, true);
        LangAdder.Add(RF_2, L1.SECONDNAME + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_3, L1.DETAILEDNOSPECIAL + " " + L1.ADDRESS, true);
        LangAdder.Add(RF_3, L1.ADDRESS + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_4, L1.DETAILEDNOSPECIAL + " " + L1.CITY, true);
        LangAdder.Add(RF_4, L1.CITY + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_5, L1.DETAILEDNOSPECIAL + " " + L1.STATEPROVINCE, true);
        LangAdder.Add(RF_5, L1.STATEPROVINCE + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(RE_6, L1.DETAILEDNOSPECIAL + " " + L1.ZIPCODE, true);
        LangAdder.Add(RF_6, L1.ZIPCODE + " " + U3900.FIELDISREQUIRED, true);
        LangAdder.Add(AccountTypeValidator, U6000.SELECTACCOUNTTYPE, true);

        //Check detailed info
        if (AppSettings.Authentication.DetailedRegisterFields)
        {
            DetailedPanel.Visible = true;
        }

        AvailableRolesPlaceHolder.Visible     = !AppSettings.Registration.IsDefaultRegistrationStatusEnabled;
        EarnerCheckBoxPlaceHolder.Visible     = AppSettings.TitanFeatures.EarnersRoleEnabled;
        AdvertiserCheckBoxPlaceHolder.Visible = AppSettings.TitanFeatures.AdvertisersRoleEnabled;
        PublisherCheckBoxPlaceHolder.Visible  = AppSettings.TitanFeatures.PublishersRoleEnabled;

        if (AppSettings.Registration.IsDefaultRegistrationStatusEnabled)
        {
            EarnerCheckBox.Checked     = AppSettings.Registration.IsDefaultEarnerStatus;
            AdvertiserCheckBox.Checked = AppSettings.Registration.IsDefaultAdvertiserStatus;
            PublisherCheckBox.Checked  = AppSettings.Registration.IsDefaultPublisherStatus;
        }

        //Custom field
        CustomFields.Controls.Add(RegistrationFieldCreator.Generate());

        CountryInformation CIService = new CountryInformation(IP.Current);

        CountryName.Text = CIService.CountryName;
        Flag.ImageUrl    = "~/Images/Flags/" + CIService.CountryCode.ToLower() + ".png";
    }
示例#22
0
    public static void Register(string InUsername, string InEmail, int InPIN, DateTime InBirthYear, string InPassword, string InReferer, Gender InGender, Panel CustomFields,
                                string FirstName, string SecondName, string Address, string City, string StateProvince, string ZipCode, bool isEarner, bool isAdvertiser, bool isPublisher, string FacebookId = null,
                                bool skipRedirection = false)
    {
        AppSettings.Email.Reload();

        bool IsFromFacebookOAuth = FacebookId != null ? true : false;

        // 0. Logged-in check
        if (Member.IsLogged)
        {
            throw new MsgException(U5009.LOGOUTTOREGISTER);
        }

        // 1. Validate if Username is not taken
        if (Member.Exists(InUsername))
        {
            throw new MsgException(L1.ER_INVALIDUSERNAME3);
        }

        // Or forbidden
        if (!SecurityManager.IsOkWithRules(SecurityRuleType.Username, InUsername) || InUsername.Contains("refback"))
        {
            throw new MsgException(L1.UNAMEFORBID);
        }

        // 2. Validate if Email is not taken
        if (Member.ExistsWithEmail(InEmail))
        {
            throw new MsgException(L1.ER_DUPLICATEEMAIL);
        }

        string             currentip = IP.Current;
        CountryInformation CIService = new CountryInformation(currentip);

        // 0. Validate if Country/IP is not forbidden
        if (!SecurityManager.IsOkWithRules(SecurityRuleType.IP, currentip))
        {
            throw new MsgException(L1.IPFORBID);
        }

        if (!SecurityManager.IsOkWithRules(SecurityRuleType.Country, CIService.CountryName))
        {
            throw new MsgException(L1.COUNTRYFORBID);
        }

        // Validate if IP is not a proxy
        if (AppSettings.Proxy.IPPolicy == IPVerificationPolicy.EveryRegistration && ProxyManager.IsProxy(currentip))
        {
            throw new MsgException(L1.IPAPROXY);
        }

        if (AppSettings.Site.AllowOnlyOneRegisteredIP)
        {
            int membersRegisteredWithThisIP = (int)TableHelper.SelectScalar(
                String.Format("SELECT COUNT(*) FROM Users WHERE RegisteredWithIP = '{0}'", currentip));

            if (membersRegisteredWithThisIP > 0)
            {
                throw new MsgException(U5005.IPALREADYREGISTERED);
            }
        }

        AppSettings.DemoCheck();

        //Validate if country is OK
        FeatureManager Manager = null;

        if (IsFromFacebookOAuth)
        {
            Manager = new FeatureManager(GeolocatedFeatureType.FacebookRegistration);
        }
        else
        {
            Manager = new FeatureManager(GeolocatedFeatureType.Registration);
        }

        if (!Manager.IsAllowed)
        {
            throw new MsgException(U4000.SORRYCOUNTRY);
        }

        // All data is OK. Now lets register
        Member NewMember = new Member();

        NewMember.Name            = InUsername;
        NewMember.Email           = InEmail;
        NewMember.PIN             = InPIN;
        NewMember.BirthYear       = InBirthYear;
        NewMember.PrimaryPassword = MemberAuthenticationService.ComputeHash(InPassword);
        NewMember.FacebookOAuthId = FacebookId;

        //Detailed info?
        if (AppSettings.Authentication.DetailedRegisterFields)
        {
            NewMember.FirstName     = FirstName;
            NewMember.SecondName    = SecondName;
            NewMember.Address       = Address;
            NewMember.City          = City;
            NewMember.StateProvince = StateProvince;
            NewMember.ZipCode       = ZipCode;
            NewMember.Gender        = InGender;
        }

        //Custom fields?
        RegistrationFieldCreator.Save(NewMember, CustomFields);

        NewMember.CameFromUrl                     = (HttpContext.Current.Session == null || HttpContext.Current.Session["ReferralFrom"] == null) ? "Unknown" : HttpContext.Current.Session["ReferralFrom"].ToString().Replace("www.", "");
        NewMember.Country                         = CIService.CountryName;
        NewMember.CountryCode                     = CIService.CountryCode;
        NewMember.MessageSystemTurnedOn           = true;
        NewMember.RevenueShareAdsWatchedYesterday = 1000; //No yesterday, that is why we assume that he watched all
        NewMember.PointsBalance                   = 0;

        //Slot Machine Modlue
        if (AppSettings.TitanFeatures.SlotMachineEnabled)
        {
            try
            {
                NewMember.PointsBalance = (int)HttpContext.Current.Session["anonymousSlotMachinePoints"];
            }
            catch (Exception slotError)
            {
                NewMember.SlotMachineChances = 1;
                ErrorLogger.Log(slotError);
            }
        }

        //Account type
        NewMember.IsEarner     = isEarner;
        NewMember.IsAdvertiser = isAdvertiser;
        NewMember.IsPublisher  = isPublisher;

        // Check if instant register or requires activation

        if (AppSettings.Authentication.IsInstantlyActivated || AppSettings.IsDemo || IsFromFacebookOAuth)
        {
            //Adding referer and points bonus
            NewMember.TryAddReferer(InReferer);

            //Add history entry
            History.AddRegistration(NewMember.Name);

            //Representatives policy
            TrySetRepresentativeAsReferer(NewMember, CIService);

            if (AppSettings.Proxy.SMSType == ProxySMSType.EveryRegistration)
            {
                NewMember.Register(MemberStatus.AwaitingSMSPIN);
            }
            else
            {
                if (NewMember.HasReferer)
                {
                    var list = new List <RestrictionKind>(new RestrictionKind[] { RestrictionKind.DirectReferralsCount });
                    LeadershipSystem.CheckSystem(list, new Member(NewMember.ReferrerId));
                }
                NewMember.Register(MemberStatus.Active);
            }

            //Registration Bonus
            TryApplyRegistrationBonus(Manager, NewMember);

            //Matrix
            MatrixBase matrix = MatrixFactory.GetMatrix();
            if (matrix != null)
            {
                matrix.TryAddMember(NewMember);
            }

            if (!skipRedirection)
            {
                HttpContext.Current.Response.Redirect("~/status.aspx?type=registerok&id=register1");
            }
        }
        else
        {
            try
            {
                Mailer.SendActivationLink(InUsername, InEmail);

                //Representatives policy
                TrySetRepresentativeAsReferer(NewMember, CIService);

                //Adding referer and points bonus
                NewMember.TryAddReferer(InReferer);

                NewMember.Register(MemberStatus.Inactive);

                //Add history entry
                History.AddRegistration(NewMember.Name);

                //Registration Bonus
                TryApplyRegistrationBonus(Manager, NewMember);

                //Matrix
                MatrixBase matrix = MatrixFactory.GetMatrix();
                if (matrix != null)
                {
                    matrix.TryAddMember(NewMember);
                }
            }
            catch (Exception ex)
            {
                ErrorLogger.Log(ex);
                throw new MsgException("The system was unable to send the activation e-mail. Contact the administrator.");
            }

            if (!skipRedirection)
            {
                HttpContext.Current.Response.Redirect("~/status.aspx?type=registerok&id=register2");
            }
        }
    }