async private void Button_Clicked_In(object sender, EventArgs e)
        {
            try
            {
                IsBusy = true;
                IGeolocator locator = CrossGeolocator.Current;
                locator.DesiredAccuracy = 50;
                Position position = await locator.GetPositionAsync(TimeSpan.FromSeconds(10));

                AttendanceModel model = new AttendanceModel()
                {
                    IsMockedLocation = App._IsMockLocation.ToString(),
                    Latitude         = Convert.ToString(position.Latitude),
                    Longitude        = Convert.ToString(position.Longitude),
                    UserId           = Convert.ToString(App._UserId),
                    AttendanceMode   = "IN"
                };

                await CallApiForAttendance(model);
            }
            catch (Exception ex)
            {
                lblMessage.Text      = ex.Message;
                lblMessage.TextColor = Color.Red;
            }
            finally
            {
                IsBusy = false;
            }
        }
        private async System.Threading.Tasks.Task CallApiForAttendance(AttendanceModel model)
        {
            try
            {
                AttendanceModel resultobject = await PostAttendance(model);

                if (resultobject.ResponseCode == 200)
                {
                    btnIn.IsVisible      = false;
                    btnOut.IsVisible     = false;
                    btnExit.IsVisible    = true;
                    lblMessage.Text      = resultobject.Message;
                    lblMessage.TextColor = Color.Green;
                }
                else if (resultobject.ResponseCode == 99)
                {
                    lblMessage.Text      = resultobject.Message;
                    lblMessage.TextColor = Color.Red;
                }
                else
                {
                    lblMessage.Text      = "Something went wrong. Please retry or contact Aegis.";
                    lblMessage.TextColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                lblMessage.Text      = ex.Message;
                lblMessage.TextColor = Color.Red;
            }
        }
        public static async System.Threading.Tasks.Task <AttendanceModel> GetAttendanceState(AttendanceModel model)
        {
            AttendanceModel resultobject    = new AttendanceModel();
            string          serializedModel = JsonConvert.SerializeObject(model);
            string          response        = await ApiAsyncPost(serializedModel, "GetAttendanceState");

            resultobject = JsonConvert.DeserializeObject <AttendanceModel>(response);
            return(resultobject);
        }
        async protected override void OnAppearing()
        {
            try
            {
                AttendanceModel model = new AttendanceModel()
                {
                    UserId         = Convert.ToString(App._UserId),
                    AttendanceMode = "GETSTATE"
                };

                AttendanceModel resultobject = await GetAttendanceState(model);

                if (resultobject.ResponseCode == 200)
                {
                    if (resultobject.CurrentState.ToLower().Equals("in"))
                    {
                        btnIn.IsVisible   = false;
                        btnOut.IsVisible  = true;
                        btnExit.IsVisible = false;
                    }
                    else
                    {
                        btnIn.IsVisible   = true;
                        btnOut.IsVisible  = false;
                        btnExit.IsVisible = false;
                    }
                }
                else if (resultobject.ResponseCode == 99)
                {
                    lblMessage.Text      = resultobject.Message;
                    lblMessage.TextColor = Color.Red;
                }
                else
                {
                    lblMessage.Text      = "Something went wrong. Please retry or contact Aegis.";
                    lblMessage.TextColor = Color.Red;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                lblMessage.Text      = ex.Message;
                lblMessage.TextColor = Color.Red;
            }
        }