Example #1
0
        protected async void newEmployeeDetails(object sender, System.EventArgs e)
        {
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(Url);
                try
                {
                    TimeLogger newEmpObject = new TimeLogger
                    {
                        FirstName  = lbl_fName.Text,
                        LastName   = lbl_lName.Text,
                        LoggedDate = lbl_date.Date
                    };
                    var inputRequest = JsonConvert.SerializeObject(newEmpObject);
                    var content      = new StringContent(inputRequest, Encoding.UTF8, "application/json");
                    var response     = await _client.PostAsync(Url, content);

                    if (response.IsSuccessStatusCode)
                    {
                        await DisplayAlert("Success", "New Employee added", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("Error", "Employee Not Added", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error", ex.Message, "Ok");
                }
            }
        }
Example #2
0
        protected async void editEmployee(TimeLogger logger, object sender, System.EventArgs e)
        {
            var id = lbl_id.Text;

            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(Url);
                try
                {
                    TimeLogger editEmpObj = new TimeLogger
                    {
                        FirstName  = lbl_fName.Text,
                        LastName   = lbl_lName.Text,
                        LoggedDate = lbl_date.Date
                    };
                    var inputRequest = JsonConvert.SerializeObject(editEmpObj);
                    var content      = new StringContent(inputRequest, Encoding.UTF8, "application/json");
                    var response     = await _client.PutAsync(Url + "/" + id, content);

                    if (response.IsSuccessStatusCode)
                    {
                        await DisplayAlert("Success", "Record Has Been Updated", "Ok");
                    }
                    else
                    {
                        await DisplayAlert("Error", "Record Not Updated", "Ok");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error", ex.Message, "Ok");
                }
            }
        }
Example #3
0
        public LoggedTimeDetails(TimeLogger logger)
        {
            if (logger == null)
            {
                throw new ArgumentException();
            }
            BindingContext = logger;

            InitializeComponent();
        }
Example #4
0
 private void listViewChanged(LoggedTimeDetails source, TimeLogger logger)
 {
     postsListView.ItemsSource = logger.ToString();
 }