예제 #1
0
 private bool IsValidate()
 {
     if (txtCurrentPassword.Text == string.Empty)
     {
         BTProgressHUD.ShowToast("Please fill required fields.", false, 1000);
         return(false);
     }
     else if (txtNewPassword.Text == string.Empty)
     {
         BTProgressHUD.ShowToast("Please fill required fields.", false, 1000);
         return(false);
     }
     else if (txtConfirmPassword.Text == string.Empty)
     {
         BTProgressHUD.ShowToast("Please fill required fields.", false, 1000);
         return(false);
     }
     else if (txtConfirmPassword.Text != txtNewPassword.Text)
     {
         BTProgressHUD.ShowToast("New password and confirm password did not mached.", false, 1000);
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #2
0
        public async void AsyncGetUserCurrentLocations(LocationUpdatedEventArgs e)
        {
            NetworkStatus remoteHostStatus = Reachability.RemoteHostStatus();

            if (remoteHostStatus == NetworkStatus.NotReachable)
            {
                var alert = UIAlertController.Create("Network Error", "Please check your internet connection", UIAlertControllerStyle.Alert);
                alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                PresentViewController(alert, animated: true, completionHandler: null);

                return;
            }

            CLLocation location = e.Location;

            ServiceManager jobService      = new ServiceManager();
            string         currentLocation = await jobService.AsyncGetUserCurrentLocations(location.Coordinate.Latitude.ToString(), location.Coordinate.Longitude.ToString());

            Console.WriteLine("location :=  " + currentLocation);

            if (string.IsNullOrEmpty(currentLocation))
            {
                BTProgressHUD.ShowToast("Unable to track location.Please try later...", false, 3000);
            }
            else
            {
                txtLocation.Text = currentLocation;
            }
        }
예제 #3
0
        private void Process(SettingsModel sm)
        {
            int ResponseCode = 0;

            try
            {
                BTProgressHUD.Show();
                Task.Factory.StartNew(
                    // tasks allow you to use the lambda syntax to pass wo
                    () =>
                {
                    ResponseCode = WebService.SaveSettings(sm);
                }                        ///
                    ).ContinueWith(
                    t =>
                {
                    if (ResponseCode == 200)
                    {
                        SaveSettings(this, null);
                        BTProgressHUD.ShowToast("Settings Saved successfully.", false, 1000);
                        this.DismissModalViewController(false);
                    }
                    else
                    {
                        BTProgressHUD.ShowToast("Failed to save settings.", false, 1000);
                    }
                    BTProgressHUD.Dismiss();
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            }
            catch (Exception ex)
            {
            }
        }
예제 #4
0
 public override void Toast(string message, int timeoutSeconds = 3, Action onClick = null)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(() => {
         var ms = timeoutSeconds * 1000;
         BTProgressHUD.ShowToast(message, false, ms);
     });
 }
예제 #5
0
        private void LoginClicked()
        {
            try
            {
                //txtUserid.Text = txtLogin_up.Text;
                //txtPassword.Text = txtPassword_up.Text;

                if (!StaticMethods.IsConnectedToInternet())
                {
                    BTProgressHUD.ShowToast("You are not connected to internet.", false, 1000);
                }
                else
                {
                    if (IsValidate())
                    {
                        if (txtLogin_up.Text != string.Empty)
                        {
                            txtUserid.Text   = txtLogin_up.Text;
                            txtPassword.Text = txtPassword_up.Text;
                        }
                        LoginProcess(txtUserid.Text, txtPassword.Text);;
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #6
0
 private async void GetContactNo()
 {
     try
     {
         BTProgressHUD.Show();
         Task.Factory.StartNew(
             // tasks allow you to use the lambda syntax to pass wor
             () =>
         {
             ContactNo = WebService.GetContactNo();
         }).ContinueWith(
             t =>
         {
             if (ContactNo != string.Empty)
             {
             }
             else
             {
                 BTProgressHUD.ShowToast("Unable to fetch contact details.", false, 1000);
             }
             BTProgressHUD.Dismiss();
         }, TaskScheduler.FromCurrentSynchronizationContext()
             );
     }
     catch (Exception ex)
     {
     }
     finally
     {
     }
 }
예제 #7
0
        private void Process()
        {
            int ResponseCode = 0;

            try
            {
                BTProgressHUD.Show();
                Task.Factory.StartNew(
                    // tasks allow you to use the lambda syntax to pass wo
                    () =>
                {
                    ResponseCode = WebService.ForgotPassword(txtEmail.Text);
                }                        ///
                    ).ContinueWith(
                    t =>
                {
                    if (ResponseCode == 200)
                    {
                        BTProgressHUD.ShowToast("A link was sent on your email address please check your inbox to change  your password.", false, 1000);
                    }
                    else
                    {
                        BTProgressHUD.ShowToast("Please enter a valid email.", false, 1000);
                    }
                    BTProgressHUD.Dismiss();
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            }
            catch (Exception ex)
            {
            }
        }
예제 #8
0
        public override void LoadView()
        {
            base.LoadView();
            View.BackgroundColor = UIColor.LightGray;

            MakeButton("Show", () => {
                BTProgressHUD.Show();
                KillAfter();
            });

            MakeButton("Show Message", () => {
                BTProgressHUD.Show(status: "Processing your image");
                KillAfter();
            });

            MakeButton("Show Success", () => {
                BTProgressHUD.ShowSuccessWithStatus("Great success!");
            });

            MakeButton("Show Fail", () => {
                BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
            });

            MakeButton("Toast", () => {
                BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false);
            });


            MakeButton("Dismiss", () => {
                BTProgressHUD.Dismiss();
            });

            MakeButton("Progress", () => {
                progress = 0;
                BTProgressHUD.Show("Hello!", progress);
                if (timer != null)
                {
                    timer.Invalidate();
                }
                timer = NSTimer.CreateRepeatingTimer(0.5f, delegate {
                    progress += 0.1f;
                    if (progress > 1)
                    {
                        timer.Invalidate();
                        timer = null;
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Show("Hello!", progress);
                    }
                });
                NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
            });

            MakeButton("Dismiss", () => {
                BTProgressHUD.Dismiss();
            });
        }
예제 #9
0
 public override void Toast(string message, int timeoutSeconds, Action onClick)
 {
     // TODO: no click callback in showtoast at the moment
     this.Dispatch(() => {
         var ms = timeoutSeconds * 1000;
         BTProgressHUD.ShowToast(message, false, ms);
     });
 }
예제 #10
0
 public override void Toast(string message, int timeoutSeconds, Action onClick)
 {
     // TODO: no click callback in showtoast at the moment
     Device.BeginInvokeOnMainThread(() => {
         var ms = timeoutSeconds * 1000;
         BTProgressHUD.ShowToast(message, false, ms);
     });
 }
예제 #11
0
 // Display Validation Message
 public void ShowValidationMessage(string alertMessage)
 {
     try
     {
         BTProgressHUD.ShowToast(alertMessage, true, 1000);
     }
     catch (Exception ex)
     { }
 }
예제 #12
0
 //TODO: ShowToast without mask?
 public override void ShowToast(string message, MaskType mask = MaskType.None, ToastPosition position = ToastPosition.None, TimeSpan?timeout = default(TimeSpan?), Action clickCallback = null, Action cancelCallback = null)
 {
     if (position == ToastPosition.None)
     {
         BTProgressHUD.ShowToast(message, (ProgressHUD.MaskType)mask + 1, true, timeout.HasValue ? timeout.Value.TotalMilliseconds : 1000);
     }
     else
     {
         BTProgressHUD.ShowToast(message, (ProgressHUD.ToastPosition)position, timeout.HasValue ? timeout.Value.TotalMilliseconds : 1000);
     }
 }
예제 #13
0
 public override void Toast(string message, int timeoutSeconds, Action onClick, MaskType maskType)
 {
     UIApplication.SharedApplication.InvokeOnMainThread(() => {
         var ms = timeoutSeconds * 1000;
         BTProgressHUD.ShowToast(
             message,
             maskType.ToNative(),
             false,
             ms
             );
     });
 }
예제 #14
0
 private bool IsValidate()
 {
     if (!Regex.Match(txtEmail.Text, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$").Success)
     {
         BTProgressHUD.ShowToast("Email is not in valid format.", false, 1000);
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #15
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);
            tblView.ReloadData();

            if (!isFavoriteJob)
            {
                this.FavoriteButtonWithCount(this.NavigationItem);
            }


            // Refine result if filter appiled.
            if (Constants.isFileterApplied && !isFavoriteJob)
            {
                if (Constants.jobSearchResponse.ContainsKey("jobList"))
                {
                    this.jobList   = Constants.jobSearchResponse["jobList"];
                    tblView.Source = new TableSource(jobList, this, this.isFavoriteJob);
                    tblView.ReloadData();
                    this.headerLabel.Text = "  " + Constants.JobCount;
                    this.appliedFilterList();
                }
            }
            else if (Constants.shouldResetFilter && !isFavoriteJob)
            {
                this.GetJobSearchData(this._keyword, this._location);
                Constants.shouldResetFilter = false;
                this.appliedFilterList();
            }


            if (isFavoriteJob || this.jobList.Count < 1)
            {
                custmFooterView.Hidden        = true;
                horizontalSepratorView.Hidden = true;
                verticalSeprator.Hidden       = true;
            }

            if (isFavoriteJob)
            {
                CGRect frame = this.tblView.Frame;
                frame.Height      += 40;
                this.tblView.Frame = frame;
            }


            if (jobList.Count < 1)
            {
                BTProgressHUD.ShowToast("No record found.", false, 3000);
            }
        }
예제 #16
0
 partial void BtnSubmit_TouchUpInside(UIButton sender)
 {
     if (!StaticMethods.IsConnectedToInternet())
     {
         BTProgressHUD.ShowToast("You are not connected to internet.", false, 1000);
     }
     else
     {
         if (IsValidate())
         {
             Process();
         }
     }
 }
예제 #17
0
        public virtual void ShowToast(string text, bool isError = false)
        {
            this.IsShowing = true;
            if (isError)
            {
                //ProgressHUD.Shared.HudBackgroundColour = UIColor.FromRGB (255, 205, 210);
                ProgressHUD.Shared.HudForegroundColor = UIColor.FromRGB(244, 67, 54);
            }
            else
            {
                //ProgressHUD.Shared.HudBackgroundColour = UIColor.FromRGB (200, 230, 201);
                ProgressHUD.Shared.HudForegroundColor = UIColor.FromRGB(0, 178, 16);
            }

            BTProgressHUD.ShowToast(text, ProgressHUD.MaskType.Clear, false, 2000);
        }
예제 #18
0
 private bool IsValidate()
 {
     if (txtUserid.Text == string.Empty)
     {
         BTProgressHUD.ShowToast("Username required.", false, 1000);
         return(false);
     }
     else if (txtPassword.Text == string.Empty)
     {
         BTProgressHUD.ShowToast("Password required.", false, 1000);
         return(false);
     }
     else
     {
         return(true);
     }
 }
예제 #19
0
        private void SetData()
        {
            try
            {
                Login.dictionary = NSUserDefaults.StandardUserDefaults.DictionaryForKey(Login.key);

                string UserName       = Login.dictionary["UserName"].ToString();
                string user_email     = Login.dictionary["user_email"].ToString();
                string first_name     = Login.dictionary["first_name"].ToString();
                string middle_name    = Login.dictionary["middle_name"].ToString();
                string family_name    = Login.dictionary["family_name"].ToString();
                string contact_number = Login.dictionary["contact_number"].ToString();
                string mobile_number  = Login.dictionary["mobile_number"].ToString();
                if (!string.IsNullOrEmpty(UserName))
                {
                    txtUsername.Text   = UserName;
                    txtFirstname.Text  = first_name.Replace("\"", string.Empty).Trim();
                    txtMiddlename.Text = middle_name.Replace("\"", string.Empty).Trim();
                    txtFamilyname.Text = family_name.Replace("\"", string.Empty).Trim();
                    txtMobileno.Text   = contact_number.Replace("\"", string.Empty).Trim();
                    txtContactno.Text  = mobile_number.Replace("\"", string.Empty).Trim();
                    txtEmail.Text      = user_email.Replace("\"", string.Empty).Trim();

                    if (string.IsNullOrEmpty(txtMobileno.Text))
                    {
                        txtMobileno.Text = "N/A";
                    }
                    if (string.IsNullOrEmpty(txtContactno.Text))
                    {
                        txtContactno.Text = "N/A";
                    }
                    if (string.IsNullOrEmpty(txtEmail.Text))
                    {
                        txtEmail.Text = "N/A";
                    }
                }
                else
                {
                    BTProgressHUD.ShowToast("Problem on fetching details, Please try again later.", false, 10000);
                }
            }
            catch (Exception ex)
            {
            }
        }
        public void WillPresentNotification(UNUserNotificationCenter center, UNNotification notification, Action <UNNotificationPresentationOptions> completionHandler)
        {
            // Do your magic to handle the notification data
            Console.WriteLine("WillPresentNotification gaurav 1 val");

            //PreferenceHandler prefsHandler = new PreferenceHandler();
            if (PreferenceHandler.IsLoggedIn())
            {
                int roleId = PreferenceHandler.GetUserDetails().RoleId;
                if (roleId == (int)EM_PORTABLE.Utils.Constants.USER_ROLE.ADMIN)
                {
                    BTProgressHUD.ForceiOS6LookAndFeel = true;
                    BTProgressHUD.ShowToast("New Alert Received !", true, 2000.0);
                }
            }
            //UIApplication.SharedApplication.ApplicationIconBadgeNumber++;
            //UserDetails userDT = prefsHandler.GetUserDetails();

            //UIApplication.SharedApplication.ApplicationIconBadgeNumber = UIApplication.SharedApplication.ApplicationIconBadgeNumber + 1;
        }
예제 #21
0
        private bool IsValidate()
        {
            bool flag = true;

            try
            {
                if (SelectedStudentId == 0)
                {
                    flag = false;
                    BTProgressHUD.ShowToast("Select student.", false, 1000);
                    return(flag);
                }

                else if (SelectedDates != null)
                {
                    if (SelectedDates.Count <= 0)
                    {
                        flag = false;
                        BTProgressHUD.ShowToast("Select dates.", false, 1000);
                        return(flag);
                    }
                }
                else
                {
                    flag = false;
                    BTProgressHUD.ShowToast("Select dates.", false, 1000);
                    return(flag);
                }
                if (string.IsNullOrEmpty(txtReason.Text))
                {
                    BTProgressHUD.ShowToast("Enter reason.", false, 1000);
                    flag = false;
                    return(flag);
                }
            }
            catch (Exception ex)
            {
                return(flag);
            }
            return(flag);
        }
예제 #22
0
        public void SendProcess()
        {
            try
            {
                if (!txtWritehere.Text.Equals(string.Empty) || !textfield.Text.Equals(string.Empty))
                {
                    //if (IsConnected)
                    if (true)
                    {
                        if (textfield.Text != string.Empty)
                        {
                            var msg = textfield.Text;
                        }
                        else
                        {
                            var msg = txtWritehere.Text;
                        }

                        JObject j = new JObject();
                        j.Add("sessionId", StaticDataModel.SocketSessionId);
                        j.Add("message", textfield.Text);
                        j.Add("flag", "message");
                        j.Add("chat_type", "1");
                        j.Add("user_id", adminid);
                        j.Add("sender_name", fullname);
                        webSocket.Send((NSString)j.ToString());
                        addCurrentMessagesTotableview(1, 0, textfield.Text);
                        txtWritehere.Text = string.Empty;
                        textfield.Text    = string.Empty;
                    }
                }
                else
                {
                    BTProgressHUD.ShowToast("Please write message and try again!.", false, 10000);
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #23
0
        private void Process()
        {
            int ResponseCode = 0;

            try
            {
                BTProgressHUD.Show();
                Task.Factory.StartNew(
                    // tasks allow you to use the lambda syntax to pass wo
                    () =>
                {
                    ResponseCode = WebService.ChangePassword(StaticDataModel.UserName, txtCurrentPassword.Text, txtNewPassword.Text);
                }                        ///
                    ).ContinueWith(
                    t =>
                {
                    if (ResponseCode == 200)
                    {
                        BTProgressHUD.ShowToast("Password has been changed successfully.", false, 1000);
                        StudentList home = this.Storyboard.InstantiateViewController("StudentList") as StudentList;
                        if (home != null)
                        {
                            this.PresentModalViewController(home, false);
                        }
                    }
                    else
                    {
                        BTProgressHUD.ShowToast("Username or password does not match.", false, 1000);
                    }
                    BTProgressHUD.Dismiss();
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            }
            catch (Exception ex)
            {
            }
        }
예제 #24
0
        private void SubmitAbsentReport(string dates, string reason)
        {
            int responseCode = 0;

            try
            {
                BTProgressHUD.Show("Fetching List...");
                Task.Factory.StartNew(
                    // tasks allow you to use the lambda syntax to pass wor
                    () =>
                {
                    responseCode = WebService.SubmitAbsentReport(SelectedStudentId, dates, reason);
                }
                    ///
                    ).ContinueWith(
                    t =>
                {
                    if (responseCode == 200)
                    {
                        BTProgressHUD.ShowToast("absent has been added successfully.", false, 1000);
                        this.DismissViewController(false, null);
                    }
                    else
                    {
                        BTProgressHUD.ShowToast("Failed to add absent, Please try again later!.", false, 1000);
                    }
                    BTProgressHUD.Dismiss();
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }
예제 #25
0
        //set the Image at Starting Position
        private void placeImageAtInitianPosition(float X, float Y, UIImageView image)
        {
            try
            {
                Current_XPosition = X;
                Current_YPosition = Y;


                //check if the view out of screen

                if ((Current_XPosition <= 0 || Current_XPosition >= screenWidth - image.Frame.Size.Width) || (Current_YPosition <= 0 || Current_YPosition >= screenHight - image.Frame.Size.Height))
                {
                    setIntialPositionOfRobo();
                    BTProgressHUD.ShowToast("Intial Start X and Y values goes out the screen,Again I check the Position", true, 1000);
                    //Toast.MakeText(this, "Intial Start X and Y values goes out the screen,Again I check the Position", ToastLength.Short).Show();
                    return;
                }
                image.Image = UIImage.FromBundle("ic_robot.png");

                image.Frame = new CoreGraphics.CGRect(x: Current_XPosition, y: Current_YPosition, width: img_sweeper.Frame.Size.Width, height: img_sweeper.Frame.Size.Height);
            }
            catch (Exception ex)
            { }
        }
예제 #26
0
 public static void ShowToast(string message, bool centered = true, double timeoutMS = 1000)
 {
     BTProgressHUD.ShowToast(message, centered, timeoutMS);
 }
예제 #27
0
        public override void LoadView()
        {
            base.LoadView();
            View.BackgroundColor = UIColor.LightGray;

            MakeButton("Run first - off main thread", () =>
            {
                //this must be the first one to run.
                // once BTProgressHUD.ANTYTHING has been called once on the UI thread,
                // it'll be setup. So this is an initial call OFF the main thread.
                // Should except in debug.
                var task = Task.Factory.StartNew(() =>
                {
                    try
                    {
                        BTProgressHUD.Show();
                        KillAfter();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                });
            });

            MakeButton("Show", () =>
            {
                BTProgressHUD.Show();
                KillAfter();
            });

            MakeButton("Cancel problem 3", () =>
                       BTProgressHUD.Show("Cancel", () => KillAfter(), "Cancel and text")
                       );

            MakeButton("Cancel problem 2", () =>
                       BTProgressHUD.Show("Cancel", () => KillAfter())
                       );

            MakeButton("Cancel problem", () =>
                       BTProgressHUD.Show("Cancel", () => KillAfter(), "This is a multilinetext\nSome more text\n more text\n and again more text")
                       );

            MakeButton("Show Message", () =>
            {
                BTProgressHUD.Show("Processing your image", -1, ProgressHUD.MaskType.Black);
                KillAfter();
            });

            MakeButton("Show Success", () =>
            {
                BTProgressHUD.ShowSuccessWithStatus("Great success!");
            });

            MakeButton("Show Fail", () =>
            {
                BTProgressHUD.ShowErrorWithStatus("Oh, thats bad");
            });

            MakeButton("Toast", () =>
            {
                BTProgressHUD.ShowToast("Hello from the toast", showToastCentered: false, timeoutMs: 1000);
            });


            MakeButton("Dismiss", () =>
            {
                BTProgressHUD.Dismiss();
            });

            MakeButton("Progress", () =>
            {
                progress = 0;
                BTProgressHUD.Show("Hello!", progress);
                if (timer != null)
                {
                    timer.Invalidate();
                }
                timer = NSTimer.CreateRepeatingTimer(0.5f, delegate
                {
                    progress += 0.1f;
                    if (progress > 1)
                    {
                        timer.Invalidate();
                        timer = null;
                        BTProgressHUD.Dismiss();
                    }
                    else
                    {
                        BTProgressHUD.Show("Hello!", progress);
                    }
                });
                NSRunLoop.Current.AddTimer(timer, NSRunLoopMode.Common);
            });

            MakeButton("Dismiss", () =>
            {
                BTProgressHUD.Dismiss();
            });
        }
예제 #28
0
 public void ShowToast(string message)
 {
     BTProgressHUD.ShowToast(message, false, 4000);
 }
예제 #29
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();


            UIKeyboard.Notifications.ObserveWillShow((sender, e) =>
            {
                if (uiviewUPlogin.Hidden)
                {
                    uiviewUPlogin.Hidden = false;
                    if (IsfromTextfield)
                    {
                        txtPassword_up.BecomeFirstResponder();
                    }
                    else
                    {
                        txtLogin_up.BecomeFirstResponder();
                    }
                }
            });
            UIKeyboard.Notifications.ObserveWillHide((sender, e) =>
            {
                if (!uiviewUPlogin.Hidden)
                {
                    txtUserid.Text       = txtLogin_up.Text;
                    txtPassword.Text     = txtPassword_up.Text;
                    uiviewUPlogin.Hidden = true;
                }
            });

            txtUserid.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();
                return(true);
            };
            txtPassword.ShouldReturn += (textField) =>
            {
                textField.ResignFirstResponder();
                return(true);
            };
            txtPassword.EditingDidBegin += (sender, e) =>
            {
                IsfromTextfield = true;
            };
            txtUserid.EditingDidBegin += (sender, e) =>
            {
                IsfromTextfield = false;
            };

            PrepareUI();
            GetContactNo();
            uiviewCall.AddGestureRecognizer(new UITapGestureRecognizer(ro =>
            {
                if (ContactNo != string.Empty)
                {
                    ContactNo = ContactNo.Replace("\"", string.Empty).Trim();
                    UIApplication.SharedApplication.OpenUrl(NSUrl.FromString("tel://" + ContactNo));

                    //var url = new NSUrl("tel:" + ContactNo);
                    //if (!UIApplication.SharedApplication.OpenUrl(url))
                    //   {
                    //	   var av = new UIAlertView("Not supported",
                    //		 "Scheme 'tel:' is not supported on this device",
                    //		 null,
                    //		 "OK",
                    //		 null);
                    //	   av.Show();
                    //   };
                }
                else
                {
                    BTProgressHUD.ShowToast("Unable to fetch contact details.", false, 1000);
                };
            }));
        }
예제 #30
0
        private async void LoginProcess(string username, string password)
        {
            usermodel = new UserModel();
            try
            {
                BTProgressHUD.Show();
                Task.Factory.StartNew(
                    // tasks allow you to use the lambda syntax to pass wor
                    () =>
                {
                    usermodel = WebService.Login(username, password);
                }).ContinueWith(
                    t =>
                {
                    if (usermodel != null)
                    {
                        if (usermodel.result != "failed")
                        {
                            StaticDataModel.ProfilePic = usermodel.school_logo;

                            StaticDataModel.SchoolName = usermodel.school_name.Replace("\"", string.Empty).Trim();
                            usermodel.result           = usermodel.result.Replace("\"", string.Empty).Trim();
                            usermodel.responseMessage  = usermodel.responseMessage.Replace("\"", string.Empty).Trim();

                            if (usermodel.result != "failed")
                            {
                                var id            = usermodel.user_id;
                                usermodel.user_id = id.Replace("\"", string.Empty).Trim();
                                SaveUserPrefrences();
                                //static data holder
                                var ids = usermodel.user_id;
                                StaticDataModel.UserId = Convert.ToInt32(ids.Replace("\"", string.Empty).Trim());
                                Home home = this.Storyboard.InstantiateViewController("Home") as Home;
                                //if (home != null)
                                //{
                                //	this.PresentViewController(home, true, null);

                                //}
                                UIApplication.SharedApplication.KeyWindow.RootViewController = home;
                            }
                        }
                        else
                        {
                            BTProgressHUD.ShowToast(usermodel.responseMessage.Replace("\"", string.Empty).Trim(), false, 10000);
                        }
                    }
                    else
                    {
                        BTProgressHUD.ShowToast("Incorrect user id or password, Please try again later.", false, 10000);
                    }
                    BTProgressHUD.Dismiss();
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            }
            catch (Exception ex)
            {
            }
            finally
            {
            }
        }