async void Delete(object sender, System.EventArgs e) { var item = (MenuItem)sender; ids = item.CommandParameter.ToString(); var deletedItem = ((EmployeeScheduleViewmodel)this.BindingContext).MYschdeule2.FirstOrDefault(d => d.Id == ids); var ans = await DisplayAlert("Confirmation message", AlertMessages.DeleteConfirmation(deletedItem.SpecificDateFormatted), "Yes", "No"); if (ans == true) { var succeed = await deletebutton.deleteData(ids, URLConfig.DeleteSchdeualurl); if (succeed) { ((EmployeeScheduleViewmodel)this.BindingContext).MYschdeule2.Remove(deletedItem); EmployeeScheduleViewmodel.tempschadual.Remove(deletedItem); EmployeeProfileHelper.EmployeeCurrentProfile.EmployeeScheduels.Remove(deletedItem); EmployeeProfileHelper.RefreshEmployeeCurrentProfile(true); await DisplayAlert(AlertMessages.Success, AlertMessages.DelteMessage, AlertMessages.OkayTitle); MonthlyControlHelper.forceReload = true; //TODO : Ash test MonthlyControlHelper.ReloadAPIData(); //TODO: Added by Ashraf to refresh the data ((EmployeeScheduleViewmodel)this.BindingContext).loadData(); if (((EmployeeScheduleViewmodel)this.BindingContext).MYschdeule2 == null) { ((EmployeeScheduleViewmodel)this.BindingContext).SlideLeft.Execute(null); } daylist.ItemsSource = ((EmployeeScheduleViewmodel)this.BindingContext).MYschdeule2; } } }
protected override async void OnAppearing() { await Task.Yield(); await MonthlyControlHelper.ReloadAPIData(); Month.Text = MonthlyControlHelper.CurrentMonth; Year.Text = MonthlyControlHelper.CurrentYear; }
protected async override void OnAppearing() { try { await Task.Yield(); //if (MonthlyControlHelper.forceReload == false) //{ // MonthlyControlHelper.forceReload = true; //} //if (MonthlyControlHelper.forceReload ) //{ MonthlyControlHelper.forceReload = true; await MonthlyControlHelper.ReloadAPIData(); Month.Text = MonthlyControlHelper.CurrentMonth; Year.Text = MonthlyControlHelper.CurrentYear; ((EmployeeScheduleViewmodel)this.BindingContext).loadData(); ((EmployeeScheduleViewmodel)this.BindingContext).get(); monlabel.TextColor = Color.White; monlabel.BackgroundColor = Color.FromHex("#f79651"); tueslabel.TextColor = Color.DimGray; tueslabel.BackgroundColor = Color.FromHex("#ecf0f1"); wedslabel.TextColor = Color.DimGray; wedslabel.BackgroundColor = Color.FromHex("#ecf0f1"); thurslabel.TextColor = Color.DimGray; thurslabel.BackgroundColor = Color.FromHex("#ecf0f1"); frilabel.TextColor = Color.DimGray; frilabel.BackgroundColor = Color.FromHex("#ecf0f1"); satlabel.TextColor = Color.DimGray; satlabel.BackgroundColor = Color.FromHex("#ecf0f1"); sunlabel.TextColor = Color.DimGray; sunlabel.BackgroundColor = Color.FromHex("#ecf0f1"); if (constants.currentDayOfWeek == 1) { var employeeSch = ((EmployeeScheduleViewmodel)this.BindingContext).Employee.EmployeeScheduels; var sch = employeeSch.FirstOrDefault(d => d.DayOfWeek == constants.currentDayOfWeek); if (sch != null) { ((EmployeeScheduleViewmodel)this.BindingContext).Timefrom = DateTime.Parse(sch.From).TimeOfDay; ((EmployeeScheduleViewmodel)this.BindingContext).Timeto = DateTime.Parse(sch.To).TimeOfDay; ((EmployeeScheduleViewmodel)this.BindingContext).TotalHours = sch.TotalHour; } else { ((EmployeeScheduleViewmodel)this.BindingContext).Timefrom = DateTime.Today.TimeOfDay; ((EmployeeScheduleViewmodel)this.BindingContext).Timeto = DateTime.Today.TimeOfDay; ((EmployeeScheduleViewmodel)this.BindingContext).TotalHours = 0.0; } } if (timedetailviewmodel.currenttemp != null) { MonthlyControlHelper.current = null; //var date = timedetailviewmodel.data.SpecificDate; //timedetailviewmodel.currenttemp.Month = Convert.ToDateTime(timedetailviewmodel.data.SpecificDate).ToString("MMMM"); //timedetailviewmodel.currenttemp.Year = Convert.ToDateTime(timedetailviewmodel.data.SpecificDate).Year.ToString(); MonthlyControlHelper.head = timedetailviewmodel.currenttemp; ((EmployeeScheduleViewmodel)this.BindingContext).SlideLeft.Execute(null); } //} } catch (Exception e) { var logged = new LoggedException.LoggedException("Error in choosetime.xaml.cs", e); await logged.LoggAPI(); } }