Example #1
0
		public LoginObject Login(string username,string password)
		{
			LoginObject obj = new LoginObject ();

			string url = Settings.InstanceURL;

			url=url+"/api/logon";

			var logon = new
			{
				Item = new
				{
					UserName = username,
					Password = password,
					RestaurantId = Settings.RestaurantId
				}
			};

			try {

				string results= ConnectWebAPI.Request(url,logon);

				obj = Newtonsoft.Json.JsonConvert.DeserializeObject<LoginObject> (results);

				return obj;

			} catch (Exception ex) {

				return null;
			}
		}
Example #2
0
        public LoginObject Login(string username, string password)
        {
            LoginObject obj = new LoginObject();

            string url = Settings.InstanceURL;

            url = url + "/api/logon";

            var logon = new
            {
                Item = new
                {
                    UserName = username,
                    Password = password,
                }
            };

            try {
                string results = ConnectWebAPI.Request(url, logon);

                obj = Newtonsoft.Json.JsonConvert.DeserializeObject <LoginObject> (results);

                return(obj);
            } catch (Exception ex) {
                Console.WriteLine(ex.StackTrace);

                return(null);
            }
        }
Example #3
0
        private void onSuccessfulLogin(LoginObject obj)
        {
            Settings.UserId       = obj.UserId;
            Settings.Username     = obj.UserName;
            Settings.Fullname     = obj.Fullname;
            Settings.CKStaff      = obj.CKStaff;
            Settings.RestaurantId = obj.RestaurantId;

            if (cb_rememberMe.Checked)
            {
                Settings.RememberMe = true;
                Settings.Password   = password.Text;
            }
            else
            {
                Settings.RememberMe = false;
                Settings.Password   = "";
            }

            LoginController.Log(Constant.Login + "_" + this.Version);

            RunOnUiThread(() => progress.Dismiss());

            StartActivity(typeof(HomeActivity));

            this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);

            this.Finish();
        }
Example #4
0
        private void Login()
        {
            RunOnUiThread(() => progress = new ProgressDialog(this, Resource.Style.StyledDialog));
            RunOnUiThread(() => progress.Indeterminate = true);
            RunOnUiThread(() => progress.SetMessage("Please wait..."));
            RunOnUiThread(() => progress.SetCancelable(true));
            RunOnUiThread(() => progress.Show());


            _loginService = new LoginController();

            LoginObject obj = _loginService.Login(username.Text, password.Text);

            if (obj != null)
            {
                if (obj.Success)
                {
                    onSuccessfulLogin(obj);
                }
                else
                {
                    onFailLogin(obj);
                }
            }
            else
            {
                RunOnUiThread(() => progress.Dismiss());

                RunOnUiThread(() => Toast.MakeText(this, "No Connection", ToastLength.Short).Show());
            }
        }
Example #5
0
        private void onFailLogin(LoginObject obj)
        {
            RunOnUiThread(() => progress.Dismiss());

            RunOnUiThread(() => Toast.MakeText(this, obj.ErrorMessage, ToastLength.Short).Show());
        }
Example #6
0
		private void onFailLogin(LoginObject obj)
		{
			RunOnUiThread (() => progress.Dismiss ());

			RunOnUiThread (() => Toast.MakeText (this, obj.ErrorMessage, ToastLength.Short).Show ());
		}
Example #7
0
		private void onSuccessfulLogin(LoginObject obj)
		{
			Settings.UserId = obj.UserId;
			Settings.Username = obj.UserName;
			Settings.Fullname = obj.Fullname;
			Settings.CKStaff = obj.CKStaff;
			Settings.RestaurantId = obj.RestaurantId;

			if (cb_rememberMe.Checked) {
				Settings.RememberMe = true;
				Settings.Password = password.Text;
			} else {
				Settings.RememberMe = false;
				Settings.Password = "";
			}

			LoginController.Log(Constant.Login+"_"+this.Version);

			RunOnUiThread (() => progress.Dismiss ());

			StartActivity(typeof(HomeActivity));

			this.OverridePendingTransition(Resource.Animation.slide_in_top, Resource.Animation.slide_out_bottom);

			this.Finish();
		}