Beispiel #1
0
 public void TestAccountListAddGet()
 {
     Account newAccount = new Account();
     newAccount.name = "Алекс";
     AccountList.Add(newAccount);
     Assert.Equals(newAccount, AccountList.Get());
 }
Beispiel #2
0
 public static string UserURL(Account account)
 {
     if (string.IsNullOrEmpty(account.name))
         return string.Format("/user/id/{0}", account.id);
     else
         return string.Format("/user/{0}", account.name);
 }
Beispiel #3
0
 public void TestAccountAreaEquals()
 {
     Account newAccount = new Account();
     newAccount.name = "Алекс";
     Account newAccount1 = new Account();
     newAccount.name = "Алекс";
     Assert.Equals(newAccount == newAccount1, newAccount.Equals(newAccount1));
 }
Beispiel #4
0
        public List<LocationArea> locationAreas = null; // http://api.yandex.ru/maps/doc/jsapi/2.x/ref/reference/Clusterer.xml

        #endregion Fields

        #region Methods

        protected void Page_Load(object sender, EventArgs e)
        {
            //Check user
            if (RouteData.Values["userId"] != null)
            {
                int id;
                if (int.TryParse(RouteData.Values["userId"].ToString(), out id))
                {
                    Account account = AccountList.Get(id);
                    if (account != null)
                    {
                        this.account = account;
                        this.locationAreas = LocationList.GetByAccount(account.id);
                    }
                    else
                    {
                        Response.Redirect("/profile");
                    }
                }
                else
                {
                    Response.Redirect("/profile");
                }
            }
            else if (RouteData.Values["userLogin"] != null)
            {
                Account account = AccountList.GetByName(RouteData.Values["userLogin"].ToString());
                if (account != null)
                {
                    this.account = account;
                    this.locationAreas = LocationList.GetByAccount(account.id);
                }
                else
                {
                    Response.Redirect("/profile");
                }
            }
            else
            {
                Response.Redirect("/profile");
            }
        }
Beispiel #5
0
        public string Login(string email, string password)
        {
            //Example http://weblogs.asp.net/jalpeshpvadgama/archive/2010/08/29/calling-an-asp-net-web-service-from-jquery.aspx
            string result = string.Empty;
            try
            {
                Account account = AccountList.Get(email);
                if (account != null)
                {
                    if(password == account.password)
                    {
                            SessionManager.SetAccount(account);

                            result = string.Format("replace:{0}", Helper.UserControlToString("SignForm.ascx"));
                    }
                    else
                    {
                        result = "alert:Wrong email or password";
                    }
                }
                else
                {
                    Account newAccount = new Account();
                    newAccount.email = email;
                    newAccount.password = password;
                    AccountList.Add(newAccount);

                    SessionManager.SetAccount(newAccount);

                    result = string.Format("replace:{0}", Helper.UserControlToString("SignForm.ascx"));
                }
            }
            catch(Exception ex)
            {
                Logg.er.Log(ex);
            }
            return result;
        }
Beispiel #6
0
 public static void SetAccount(Account account)
 {
     System.Web.HttpContext.Current.Session["UserID"] = account.id;
 }