async private void Clicked_DeleteTeam(object sender, EventArgs e) { String x = await DisplayActionSheet("Are you sure you want to Delete this team?", "Cancel", "Delete Team"); if (x == "Cancel") { return; } else { // TeamsDashboardPage3.test1.Remove(CurrentTeamDetails); //HERE WE NEED TO REMOVE THE ITEM FROM DATABASE TOO OR SOMETHING result = await Api_Connector.Connect(String.Format(Api_Url_Admin, CurrentTeamDetails.Team_Id)); switch (result) { case "0": DisplayAlert("Error", "Contact us.", "OK"); return; case "1": DisplayAlert("Done", "Team is Deleted", "OK"); Navigation.RemovePage(this); return; default: DisplayAlert("Error", "Contact us.", "OK"); Navigation.RemovePage(this); return; } } }
private async void GetReports() { try { result = JsonConvert.DeserializeObject <result_Reports>(await Api_Connector.Connect(String.Format(URL, "Me", TeamInterfacePageUser8.Team_Id))); } catch (Exception e) { result = new result_Reports { list = new List <Requested_Report>() }; } if (result.Value == 1 && result.list != null) { foreach (Requested_Report x in result.list) { x.Description = x.Description.Replace("\\n", "\n"); test4.Add(x); } } else { result.list = new List <Requested_Report>(); } ReportsSentList.ItemsSource = test4; }
private async void connection_check() { for (int i = 0; i < 3; i++) { result = await Api_Connector.Connect(Url2); if (result.ToString().Equals("111")) { EntryEmail.IsEnabled = true; EntryPassword.IsEnabled = true; if (Disabled == true) { Disabled = false; successlabel.IsVisible = true; } RetryButton.IsVisible = false; RetryLabel.IsVisible = false; return; } } EntryEmail.IsEnabled = false; EntryPassword.IsEnabled = false; Disabled = true; RetryButton.IsVisible = true; RetryLabel.IsVisible = true; return; }
private async void RemoveMemberClicked(object sender, EventArgs e) { var menuitem = sender as MenuItem; var team_member = menuitem.CommandParameter as Get_TeamMembers_Result.Team_Member; var x = await DisplayActionSheet("Are you sure you want to remove this team member?", "Cancel", "Remove"); if (x == "Cancel") { return; } string result = await Api_Connector.Connect(String.Format(remove_member, Team_ID, team_member.USID)); if (result.Equals("1")) { members_lists.Remove(team_member); } else if (result.Equals("2")) { await DisplayAlert("Error", "You can't remove yourself as the group Admin from here.", "ok"); } else { await DisplayAlert("Error", "Please check your connection and try again.", "OK"); } //we need code here to remove from database too }
async private void ToolbarItem_Clicked(object sender, EventArgs e) { var Team_ID = "here is here u give me ID and pass then use them in the display alert below"; string pass = "******"; pass = await Api_Connector.Connect(String.Format(Api_Team_Pass, CurrentTeamDetails.Team_Id)); await DisplayAlert("Team Information", "Team ID:\"" + CurrentTeamDetails.Team_Id + "\"\nTeam Password: "******"Close"); }
async private void Clicked_Signout(object sender, EventArgs e) { LoginPage1.Globalproperties.UserName = ""; await Api_Connector.Connect(URL2); await Navigation.PopToRootAsync(false); Navigation.RemovePage(this); //await Navigation.PopToRootAsync(); }
async private void Clicked_SendAnnouncement(object sender, EventArgs e) { result = await Api_Connector.Connect(String.Format(URL, Title_Entry.Text, Team_ID, Ann_Content.Text, DateTime.Now.ToString())); if (result == "1") { await DisplayAlert("Notification!", "Announcement created successfully", "ok"); await Navigation.PopAsync(); } else { await DisplayAlert("Error!", "Announcement Sent Failed!", "ok"); } }
async private void ConfirmButton_Clicked(object sender, EventArgs e) { string NewTitle = NewTitleEntry.Text; // this is the new title of the user. string result = await Api_Connector.Connect(String.Format(change_title_url, user.USID, TeamInterfacePageAdmin7.Team_ID, NewTitle)); if (result.Equals("1")) { await Navigation.PopAsync(); await DisplayAlert("Notification!", "Title of Member successfully changed", "Continue"); } else { await DisplayAlert("Notification!", "Error:" + result, "Continue"); } }
private async void GetReports() { try { result = JsonConvert.DeserializeObject <result_Reports>(await Api_Connector.Connect(String.Format(URL, USID, TeamInterfacePageAdmin7.Team_ID))); } catch (Exception e) { result = new result_Reports { list = new List <Requested_Report>() }; } if (result.Value == 1) { foreach (Requested_Report x in result.list) { AllReports.Add(x); } } AllReportsList.ItemsSource = AllReports; }
private async void Getteams() { //EmptyListLabel.BindingContext = this; //NEED TO WORK ON THIS LATER try { test1 = Newtonsoft.Json.JsonConvert.DeserializeObject <ObservableCollection <Team> >(await Api_Connector.Connect(URL)); } catch { test1 = new ObservableCollection <Team>(); } JoinedTeamsList.ItemsSource = test1; }
private async void ContextDeleteClicked(object sender, EventArgs e) { var menuitem = sender as MenuItem; var team = menuitem.CommandParameter as Team; String x; if (!team.Admin) { x = await DisplayActionSheet("Are you sure you want to leave this team?", "Cancel", "Leave Team"); if (x == "Cancel") { return; } result = await Api_Connector.Connect(String.Format(Api_Url, team.Team_Id)); switch (result) { case "0": DisplayAlert("Error", "Contact us.", "OK"); return; case "1": test1.Remove(team); DisplayAlert("Done", "Team is Left Successfully", "OK"); return; case "5": DisplayAlert("Error", "Session Error", "OK"); return; default: DisplayAlert("Error", "Contact us.", "OK"); return; } } else if (team.Admin) { x = await DisplayActionSheet("Are you sure you want to Delete this team?", "Cancel", "Delete Team"); if (x == "Cancel") { return; } //PROBLEM HERE WITH RESULT GIVING "666"...PLS FIND CAUSE result = await Api_Connector.Connect(String.Format(Api_Url_Admin, team.Team_Id)); switch (result) { case "0": DisplayAlert("Error", "Contact us.", "OK"); return; case "1": test1.Remove(team); DisplayAlert("Done", "Team is Deleted", "OK"); return; default: DisplayAlert("Error", "Contact us.", "OK"); return; } } }
async void OnLoginClicked(object sender, EventArgs e) { //await Navigation.PushAsync(new TeamsDashboardPage3()); //return; if (_isBusy) { return; } if (Disabled == true) { return; } if (EntryEmail.Text.Equals("") || EntryPassword.Text.Equals("")) { await DisplayAlert("Error", "enter both email and password", "ok"); return; } if (!EntryEmail.Text.Contains("@")) { await DisplayAlert("Error", "incorrect email address", "ok"); return; } if (EntryPassword.Text.Length < 6) { await DisplayAlert("Error", "password should be at least 6 charecters", "ok"); return; } _isBusy = true; result = await Api_Connector.Connect(String.Format(Url, EntryEmail.Text, EntryPassword.Text)); switch (result.ToString()) { case "0": await DisplayAlert("Error", "Wrong Username or Password", "ok"); _isBusy = false; return; case "1": Globalproperties.UserName = await Api_Connector.Connect(Url3); await Navigation.PushAsync(new TeamsDashboardPage3()); _isBusy = false; return; case "404": await DisplayAlert("system error", "System is down\n please try again later", "ok"); _isBusy = false; return; case "666": await DisplayAlert("system error", "input error", "ok"); _isBusy = false; return; case "999": await DisplayAlert("communication error", "please check your internet connection\nand try again", "ok"); _isBusy = false; return; default: await DisplayAlert("Unknown Error", "Unknown Error", "ok"); _isBusy = false; return; } }
async private void Clicked_Confirm_Registration(object sender, EventArgs e) { if (_isBusy) { return; } foreach (Entry x in allboxes) { if (x.Text == null || x.Text.Equals("")) { x.BackgroundColor = Color.Red; entry_error = true; } } if (entry_error) { await DisplayAlert("Input Error", "Please provide all required information", "ok"); entry_error = false; return; } if (!email_reg.Text.Contains("@")) { errors += "-Please Enter a valid email.\n"; email_reg.BackgroundColor = Color.Red; entry_error = true; } else if (!email_reg.Text.Equals(re_email_reg.Text)) { re_email_reg.BackgroundColor = Color.Red; errors += "-Please Enter a valid email.\n"; entry_error = true; } if (password_reg.Text.Length < 6) { password_reg.BackgroundColor = Color.Red; errors += "-password must be at least 6 charecters.\n"; entry_error = true; } else if (!password_reg.Text.Equals(re_password_reg.Text)) { re_password_reg.BackgroundColor = Color.Red; errors += "-password and password re-entry are not the same.\n"; entry_error = true; } if (entry_error) { await DisplayAlert("Input Error", errors, "ok"); entry_error = false; return; } _isBusy = true; api_result = await Api_Connector.Connect(String.Format(api_url, email_reg.Text, password_reg.Text, Fname.Text, Lname.Text)); //0 for "email is used" // 1 for success // 5 for "input error" // 404 for "conniction errors" //666 error returned from api_connector "api error" //999 returned from api_connector "failed connection" switch (api_result) { case "0": await DisplayAlert("e-mail error", "this e-mai is already registered", "ok"); return; case "1": await DisplayAlert("success", "success", "log-in"); break; case "5": await DisplayAlert("Input error", "input error", "ok"); return; case "404": await DisplayAlert("system error", "System is down\n please try again later", "ok"); return; case "666": await DisplayAlert("system error", "input error", "ok"); return; case "999": await DisplayAlert("communication error", "please check your internet connection\nand try again", "ok"); return; default: await DisplayAlert("Unknown Error", "Unknown Error", "ok"); return; } //await Navigation.PopAsync(); LoginPage1.Globalproperties.UserName = Fname.Text + " " + Lname.Text; await Navigation.PushAsync(new TeamsDashboardPage3()); //NEED TO EDIT THIS PART _isBusy = false; Navigation.RemovePage(this); }
private async void GetAdmin() { AdminNameResult x = Newtonsoft.Json.JsonConvert.DeserializeObject <AdminNameResult>(await Api_Connector.Connect(AdminName_Url + CurrentTeamDetails.Team_Id)); if (x.Value == 1) { Admin_Name = x.AdminName; } else { Admin_Name = "Unknown"; } }
private async void GetMembers() { Get_TeamMembers_Result x = Newtonsoft.Json.JsonConvert.DeserializeObject <Get_TeamMembers_Result>(await Api_Connector.Connect(String.Format(URL, Team_ID))); if (x.result == 1) { foreach (Get_TeamMembers_Result.Team_Member y in x.Members) { members_lists.Add(y); } } TeamMembersList.ItemsSource = members_lists; }
async private void Clicked_ConfirmTeamCreation(object sender, EventArgs e) { if (_isBusy) { return; } foreach (Entry x in allboxes) { if (x.Text == null || x.Text.Equals("")) { x.BackgroundColor = Color.Red; entry_error = true; } } if (entry_error) { await DisplayAlert("Input Error", "Please provide all required information", "ok"); entry_error = false; return; } if (!passwordEntry.Text.Equals(re_PasswordEntry.Text)) { re_PasswordEntry.BackgroundColor = Color.Red; errors += "-password and password re-entry are not the same.\n"; entry_error = true; } if (entry_error) { await DisplayAlert("Input Error", errors, "ok"); entry_error = false; return; } _isBusy = true; // HERE WE NEED CODE FROM DATABASE FOR TEAM ID SO WE CAN PASS IT TO THE NEXT PAGE api_result = await Api_Connector.Connect(String.Format(URL, TeamNameEntry.Text, passwordEntry.Text.Trim())); Create_Team_result created = Newtonsoft.Json.JsonConvert.DeserializeObject <Create_Team_result>(api_result); var NewlyCreatedTeam = new Team(created.ID, TeamNameEntry.Text, "Admin", true, false, false, false, false); if (created.result == 1) { await Navigation.PushAsync(new TeamIdPage6(NewlyCreatedTeam, passwordEntry.Text)); } _isBusy = false; //Team NewCreatedTeam = new Team() //{ // Team_Id = "123", //TEAM ID FROM DATABASE // Team_Name = TeamNameEntry.Text, // Admin = 1 // // HOW WILL PASSWORD BE SAVED IN DATABASE? PUT IT HERE SOMEHOW? //}; //TeamsDashboardPage3.test1.Add(NewlyCreatedTeam); Navigation.RemovePage(this); }
public MainPageViewModel() { this.SelectedProviderChanged = new Command((nothing) => { if (PLEASEWORK == "Create New Task") { Visibility = true; } else { Visibility = false; EntryContent = ""; } }); //INSIDE THIS FUNCTION BELOW YOU NEED TO GIVE ME THE LIST OF TASK NAMES FOR THIS SPECIFIC TEAM //FROM THE DATABASE. YOU NEED TO REPLACE THE : new ObservableCollection<string>. GetTaskNamesFromDB(); Visibility = false; //END OF SHIT SHOW this.CurrentYearText = Convert.ToString(DateTime.Today.Year); this.CurrentMonthText = DateTimeFormatInfo.CurrentInfo.GetMonthName(DateTime.Today.Month); CalendarDays = new List <Day>(); SavedReports = new List <Day>(); // create 42 objects for the CalendarDays collection for (int i = 0; i < 42; i++) { CalendarDays.Add(new Day()); //var Cell = new Day(); } CalendarFunc(); this.RightArrowClick = new Command((nothing) => { BeforeSwitchingMonth(); SelectedDate = SelectedDate.AddMonths(1); CurrentMonthText = DateTimeFormatInfo.CurrentInfo.GetMonthName(SelectedDate.Month); CalendarFunc(); if (SelectedDate.Month == 1) { CurrentYearText = Convert.ToString(Convert.ToInt32(SelectedDate.Year)); } AfterSwitchingMonth(); }); this.LeftArrowClick = new Command((nothing) => { BeforeSwitchingMonth(); SelectedDate = SelectedDate.AddMonths(-1); CurrentMonthText = DateTimeFormatInfo.CurrentInfo.GetMonthName(SelectedDate.Month); CalendarFunc(); if (SelectedDate.Month == 12) { CurrentYearText = Convert.ToString(Convert.ToInt32(SelectedDate.Year)); } AfterSwitchingMonth(); }); this.SendReportButton = new Command(async(nothing) => { if ((string.IsNullOrWhiteSpace(PLEASEWORK) && Visibility == false) || (string.IsNullOrWhiteSpace(EntryContent) && Visibility == true)) { await App.Current.MainPage.DisplayAlert("Attention!", "Please enter a task name or select a task from the ones provided", "Ok"); return; } if (string.IsNullOrWhiteSpace(Description)) { bool answer = await App.Current.MainPage.DisplayAlert("Attention!", "Task Description field is empty, submit the report anyway?", "Yes", "No"); if (answer == false) { return; } Description = "No Description provided by the user"; } //Load = true; //foreach (var calendarDay in CalendarDays.Where(c => !string.IsNullOrEmpty(c.Entry))) //{ // var resultstest = SavedReports.Where(d => d.Date == calendarDay.Date).ToList(); // if(resultstest.Count>0) // { // resultstest.First().Entry = calendarDay.Entry; // } // else // { // NewObject = new Day(); // NewObject.Date = calendarDay.Date; // NewObject.Entry = calendarDay.Entry; // SavedReports.Add(NewObject); // } // calendarDay.Entry = null; //} equivalent to the below first linq query bool valuechanged = false; //used for the problem if (SavedReports.Count == 0) //used for the problem { NewObject = new Day(); SavedReports.Add(NewObject); valuechanged = true; } var results = from a in CalendarDays //pre-save step from b in SavedReports where !string.IsNullOrEmpty(a.Entry) select new { itemA = a, itemB = b }; foreach (var result in results.ToList()) { if (result.itemB.Date == result.itemA.Date) //check if saved reports has a record of this cell { result.itemB.Entry = result.itemA.Entry; result.itemA.Entry = null; result.itemB.Exist = true; } } foreach (var result in results.ToList()) { if (result.itemA.Entry != null) //if no pre-existing object of this cell exists, create one { NewObject = new Day { Date = result.itemA.Date, Entry = result.itemA.Entry, Exist = true }; result.itemA.Entry = null; SavedReports.Add(NewObject); } } if (valuechanged == true) { SavedReports.RemoveAt(0); } // UNTIL HERE foreach (Day item in SavedReports.ToList()) { if (string.IsNullOrEmpty(item.Entry) && !item.Exist) //check if there is an unnecesary saved report to remove { SavedReports.Remove(item); } else if (!string.IsNullOrEmpty(item.Entry)) //save/make official entries from current and other pages already saved in //savedreports that are currently not official yet { item.Hours += double.Parse(item.Entry, CultureInfo.CurrentCulture); item.Entry = null; } } List <Day_For_Sending> temp = new List <Day_For_Sending>(); foreach (Day item in SavedReports.ToList()) { temp.Add(new Day_For_Sending(item.Date, (int)item.Hours)); } json = JsonConvert.SerializeObject(temp); //Saving by serizalizing first //DONT NEED THIS ANYMORE...OLD CODE FOR SAVING //if (Device.RuntimePlatform == Device.Windows) //checking what device is in use to use appropriate method // await SavefileWin(json); //else // DependencyService.Get<ISaveAndLoad>().SaveText("CalendarFile.txt", json); //************************** HERE ****************************** // the object FullReport below contains all the necessary, connect your thingy string TaskName = Visibility == true ? EntryContent : PLEASEWORK; var FullReport = new SendReport(TeamInterfacePageUser8.Team_Id, TaskName, Description, json); string r = await Api_Connector.Connect(String.Format(URL, TeamInterfacePageUser8.Team_Id, TaskName, Description, DateTime.Now.ToString(), json)); if (r.Equals("1")) { await App.Current.MainPage.DisplayAlert("Notification!", "Report Sent Sucessfully!", "Continue"); await App.Current.MainPage.Navigation.PopAsync(); } else { await App.Current.MainPage.DisplayAlert("Error!", r + "!!!", "OK"); } // CalendarFunc(); we dont need this anymore i think }); this.ResetButton = new Command((nothing) => { //for (int i = SavedReports.Count - 1; i >= 0; i--) //remove saved reports // SavedReports.RemoveAt(i); //THIS IS EQUIVALENT TO THE LINE CLEAR BELOW // SavedReports.Clear(); for (int i = 0; i < 42; i++) //reset calendar page { CalendarDays[i].Entry = null; } //try //THIS DELETES THE FILE AND FOLDER //{ // if (Device.RuntimePlatform == Device.Windows) // await DeleteFileWin(); // else // DependencyService.Get<ISaveAndLoad>().DeleteFile("CalendarFile.txt"); //} //catch { } //saving automatically after reseting the data in the app //json = JsonConvert.SerializeObject(SavedReports); //if (Device.RuntimePlatform == Device.Windows) // await SavefileWin(json); //else // DependencyService.Get<ISaveAndLoad>().SaveText("CalendarFile.txt", json); CalendarFunc(); }); }
private async void GetTask() { try { x = Newtonsoft.Json.JsonConvert.DeserializeObject <Tasks_Result>(await Api_Connector.Connect(String.Format(URL2, TeamInterfacePageUser8.Team_Id))); } catch (Exception e) { x = new Tasks_Result(); } if (x.Task_List != null) { foreach (string y in x.Task_List) { TaskNamesList.Add(y); } } TaskNamesList.Add("Create New Task"); }
private async void GetAnnouncments() { result = Newtonsoft.Json.JsonConvert.DeserializeObject <get_ann_result>(await Api_Connector.Connect(String.Format(URL, Team_Id))); if (result.List != null) { foreach (Announcment x in result.List) { test3.Add(new Announcment2(x.Title, x.Sender_Name, x.Content, x.Date, x.Date)); } AnnouncmentsList.ItemsSource = test3; } }
async private void Clicked_JoinTeam(object sender, EventArgs e) { // 0 for wrong team ID //1 for success //2 for wrong password //3 for already joined //5 no session //404 system is down if (_isBusy) { return; } //DisplayAlert LOGIC HERE //here we pop page once to go back to teams dashboard //line below needs to be removed but is still here for testing purpose foreach (Entry x in allboxes) { if (x.Text == null || x.Text.Equals("")) { x.BackgroundColor = Color.Red; entry_error = true; } } if (entry_error) { await DisplayAlert("Input Error", "Please provide all required information", "ok"); entry_error = false; return; } _isBusy = true; //HERE WE NEED CODE TO CHECK IF INPUT IS CORRECT WITH THE DATABASE result = await Api_Connector.Connect(String.Format(Api_Url, IdEntry.Text, PasswordEntry.Text, TitleEntry.Text)); switch (result) { case "0": await DisplayAlert("Input Error", "Wrong Team ID", "ok"); _isBusy = false; return; case "1": await DisplayAlert("Success", "Team Joined Successfully", "ok"); break; case "2": await DisplayAlert("Input Error", "Password in wrong", "ok"); _isBusy = false; return; case "3": await DisplayAlert("Error", "You already joined this team", "ok"); _isBusy = false; return; case "5": // await DisplayAlert("Err", "Please provide all required information", "ok"); return; default: return; } _isBusy = false; Navigation.RemovePage(this); }