public void TestCats() { var response = httpCommunication.Execute(UrlList.PetsUrl, null, "GET", "application/json", typeof(List <Person>)); Assert.IsTrue(CheckTypeAndData(response)); var typedResponse = (List <Person>)response; var onlyCats = new List <Pet>(); foreach (var person in typedResponse.Where(a => a.pets != null)) { foreach (var pet in person.pets.Where(a => a.type?.ToLower() == "cat")) { onlyCats.Add(pet); } } DataManip dataManip = new DataManip(); var resultFromDataManip = dataManip.GetAllCats(typedResponse, false); var firstNotSecond = onlyCats.Except(resultFromDataManip).ToList(); var secondNotFirst = resultFromDataManip.Except(onlyCats).ToList(); Assert.IsTrue(onlyCats.Count == resultFromDataManip.Count); Assert.IsFalse(!onlyCats.Any() && !secondNotFirst.Any()); }
partial void CancelButton2_TouchUpInside(UIButton sender) { DataManip.clearPassengerList(); DataManip.SetIsUpdate(false); var update = DataManip.GetIsUpdate(); UIStoryboard board = UIStoryboard.FromName("Main", null); UIViewController ctrl = (UIViewController)board.InstantiateViewController("TableController"); ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; this.PresentViewController(ctrl, true, null); }
public override void ViewDidLoad() { base.ViewDidLoad(); var tapOutSide = new UITapGestureRecognizer(() => View.EndEditing(true)); View.AddGestureRecognizer(tapOutSide); passengerList = new List <String>(); passengerList = DataManip.returnPassengerList(); fillTextFieldList(); fillTextFields(); }
partial void OkButton_TouchUpInside(UIButton sender) { List <string> newList = new List <string>(); var count = textFieldList.Count; for (int i = 0; i < count; i++) { if (textFieldList[i].Text != "") { newList.Add(textFieldList[i].Text); } } DataManip.updatePassengerList(newList); }
static void Main(string[] args) { var httpCommunication = new HttpComm(); var response = httpCommunication.Execute(UrlList.PetsUrl, null, "GET", "application/json", typeof(List <Person>)); if (!(response is List <Person>)) { Console.WriteLine($"Response is not of desired type!"); } var typedResponse = ((List <Person>)response).ToList(); DataManip dataManip = new DataManip(); dataManip.GetAllCats(typedResponse, true); Console.WriteLine("press any key..."); Console.ReadKey(); }
partial void PassengerButton_TouchUpInside(UIButton sender) { DataManip.SetIsTemp(true); DataManip.AddToTemp(DateOutTextField.Text); DataManip.AddToTemp(DateInTextField.Text); DataManip.AddToTemp(HobbsInTextField.Text); DataManip.AddToTemp(HobbsOutTextField.Text); DataManip.AddToTemp(HobbsTotalTextField.Text); DataManip.AddToTemp(CashSpentTextField.Text); DataManip.AddToTemp(pilotTextField.Text); DataManip.AddToTemp(leaseTextField.Text); DataManip.AddToTemp(FlightTypeTextField.Text); DataManip.AddToTemp(PlaneTypeTextField.Text); DataManip.AddToTemp(DestinationTextField.Text); UIStoryboard board = UIStoryboard.FromName("Main", null); UIViewController ctrl = (UIViewController)board.InstantiateViewController("PassengerView"); ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; this.PresentViewController(ctrl, true, null); }
public override void ViewDidLoad() { base.ViewDidLoad(); myScrollView.ContentSize = new CoreGraphics.CGSize( View.Frame.Width + 200, View.Frame.Height + 300); var tapOutSide = new UITapGestureRecognizer(() => View.EndEditing(true)); tapOutSide.CancelsTouchesInView = false; View.AddGestureRecognizer(tapOutSide); HideOnReturn(passenger1TextField); HideOnReturn(passenger2TextField); HideOnReturn(passenger3TextField); HideOnReturn(passenger4TextField); HideOnReturn(passenger5TextField); HideOnReturn(passenger6TextField); HideOnReturn(passenger7TextField); HideOnReturn(passenger8TextField); HideOnReturn(passenger9TextField); HideOnReturn(passenger10TextField); HideOnReturn(passenger11TextField); HideOnReturn(passenger12TextField); HideOnReturn(passenger13TextField); HideOnReturn(passenger14TextField); HideOnReturn(passenger15TextField); HideOnReturn(passenger16TextField); HideOnReturn(passenger17TextField); HideOnReturn(passenger18TextField); HideOnReturn(passenger19TextField); HideOnReturn(passenger20TextField); HideOnReturn(passenger21TextField); HideOnReturn(passenger22TextField); HideOnReturn(passenger23TextField); HideOnReturn(passenger24TextField); passengerList = new List <String>(); passengerList = DataManip.returnPassengerList(); fillTextFieldList(); fillTextFields(); }
public override void ViewDidAppear(bool animated) { DestinationTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Destination", null, UIColor.Red); HobbsInTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Hobbs Out", null, UIColor.Red); HobbsOutTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Hobbs In", null, UIColor.Red); HobbsTotalTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Total Hobbs", null, UIColor.Red); CashSpentTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Cash Spent", null, UIColor.Red); FlightTypeTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Flight Type", null, UIColor.Red); PlaneTypeTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Plane Type", null, UIColor.Red); leaseTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Lease Name", null, UIColor.Red); pilotTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Pilot", null, UIColor.Red); passengerAddTextField.AttributedPlaceholder = new Foundation.NSAttributedString("Enter Passengers", null, UIColor.Red); base.ViewDidLoad(); UIViewController vc = this; val = new validation(vc); var update = DataManip.GetIsUpdate(); var temp = DataManip.GetIsTemp(); DateOutTextField.Text = DateTime.Now.ToString("MM/dd/yyyy"); DateInTextField.Text = DateTime.Now.ToString("MM/dd/yyyy"); datePickerMaker(DateOutTextField); datePickerMaker(DateInTextField); HobbsInTextField.KeyboardType = UIKeyboardType.DecimalPad; HobbsOutTextField.KeyboardType = UIKeyboardType.DecimalPad; HobbsTotalTextField.KeyboardType = UIKeyboardType.DecimalPad; CashSpentTextField.KeyboardType = UIKeyboardType.DecimalPad; var flightList = new List <string> { "Whole Day", "Half Day", "Two Days", "Three Days", "Four Days", "Five Days", "Six Days", "Seven Days", "Eight Days", "Nine Days", "Ten Days", "_________Days" }; pickerMaker(flightList, FlightTypeTextField); stringList = dm.FillPilotPicker(); pickerMaker(stringList, pilotTextField); stringList = dm.FillLeasePicker(); pickerMaker(stringList, leaseTextField); stringList = dm.FillPlanePicker(); pickerMaker(stringList, PlaneTypeTextField); DestinationTextField.Text = ""; HobbsInTextField.Text = ""; HobbsOutTextField.Text = ""; HobbsTotalTextField.Text = ""; CashSpentTextField.Text = ""; FlightTypeTextField.Text = ""; pilotTextField.Text = ""; leaseTextField.Text = ""; if (update) { card = DataManip.GetEditCard(); DataManip.clearPassengerList(); var dateOut = card.dateOut.ToString("MM/dd/yyyy"); var dateIn = card.dateIn; var modDateOut = dateOut.Substring(0, 10); dateIn = card.dateIn.Substring(0, 10); DateOutTextField.Text = modDateOut; DateInTextField.Text = dateIn; HobbsInTextField.Text = card.hobbsIn; HobbsOutTextField.Text = card.hobbsOut; if ((card.hobbsIn != "") && (card.hobbsOut != "")) { var number = (double.Parse(card.hobbsOut) - double.Parse(card.hobbsIn)).ToString("F1"); HobbsTotalTextField.Text = number; } CashSpentTextField.Text = card.cashSpent; DestinationTextField.Text = card.destination; foreach (var passenger in card.getPassengers()) { if (passenger != "") { dm.addPassengerToList(passenger); } } PlaneTypeTextField.Text = card.planeType; pilotTextField.Text = card.pilot; leaseTextField.Text = card.leaseName; FlightTypeTextField.Text = card.flightType; } if (temp) { tempList = DataManip.GetTemp(); DateOutTextField.Text = tempList[0]; DateInTextField.Text = tempList[1]; HobbsInTextField.Text = tempList[2]; HobbsOutTextField.Text = tempList[3]; HobbsTotalTextField.Text = tempList[4]; CashSpentTextField.Text = tempList[5]; pilotTextField.Text = tempList[6]; leaseTextField.Text = tempList[7]; FlightTypeTextField.Text = tempList[8]; PlaneTypeTextField.Text = tempList[9]; DestinationTextField.Text = tempList[10]; DataManip.SetIsTemp(false); DataManip.ClearTempInfo(); } }
partial void SaveButton2_TouchUpInside(UIButton sender) { List <string> passengers = new List <string>(); var update = DataManip.GetIsUpdate(); if ((HobbsInTextField.Text != "") && (HobbsOutTextField.Text != "")) { var number = (double.Parse(HobbsOutTextField.Text) - double.Parse(HobbsInTextField.Text)).ToString("F1"); HobbsTotalTextField.Text = number; } passengers = DataManip.returnPassengerList(); if (passengers.Count != 24) { for (int i = passengers.Count; i < 24; i++) { passengers.Add(""); } } string destination = DestinationTextField.Text.Replace(',', '.'); var dateOutFromTextField = DateTime.Parse(DateOutTextField.Text); var dateOut = dateOutFromTextField.Add(DateTime.Now.TimeOfDay); var newCard = new FlightCards( dateOut, DateInTextField.Text, destination, HobbsInTextField.Text, HobbsOutTextField.Text, HobbsTotalTextField.Text, CashSpentTextField.Text, FlightTypeTextField.Text, pilotTextField.Text, PlaneTypeTextField.Text, leaseTextField.Text, passengers[0], passengers[1], passengers[2], passengers[3], passengers[4], passengers[5], passengers[6], passengers[7], passengers[8], passengers[9], passengers[10], passengers[11], passengers[12], passengers[13], passengers[14], passengers[15], passengers[16], passengers[17], passengers[18], passengers[19], passengers[20], passengers[21], passengers[22], passengers[23]); if (update) { FlightCards old = DataManip.GetEditCard(); newCard.dateOut = old.dateOut; if (Reachability.IsHostReachable("https://www.google.com")) { Toast.MakeText("Flight Card Saved!", Toast.LENGTH_LONG).Show(); dm.updateFlightCardTable(newCard); ws.updateFlightCard(newCard); } else { dm.updateFlightCardTable(newCard); dm.AddtoUpdateTable(newCard); } } else { if (Reachability.IsHostReachable("https://www.google.com")) { ws.SaveToServiceAsync(newCard); } else { dm.AddToAddTable(newCard); dm.SaveFlightCard(newCard); dm.saveAll(); } } DataManip.clearPassengerList(); DataManip.SetIsUpdate(false); UIStoryboard board = UIStoryboard.FromName("Main", null); UIViewController ctrl = (UIViewController)board.InstantiateViewController("TableController"); ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; this.PresentViewController(ctrl, true, null); }
public override void CommitEditingStyle(UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath) { switch (editingStyle) { case UITableViewCellEditingStyle.Delete: UIAlertController actionSheetAlert = UIAlertController.Create( "Menu", "Select An Action", UIAlertControllerStyle.ActionSheet); actionSheetAlert.AddAction(UIAlertAction.Create("Email", UIAlertActionStyle.Default, (obj) => { if (MFMailComposeViewController.CanSendMail) { var passengers = cards[indexPath.Row].getPassengers(); List <String> actualPassengers = new List <string>(); foreach (var person in passengers) { if (person != "") { actualPassengers.Add(person); } } String passString = "Passengers: \n"; foreach (var passenger in actualPassengers) { passString += passenger + "\n"; } var dateOut = cards[indexPath.Row].dateOut; var dateIn = cards[indexPath.Row].dateOut; var destination = cards[indexPath.Row].destination; var hobbsIn = cards[indexPath.Row].hobbsIn; var hobbsOut = cards[indexPath.Row].hobbsOut; var hobbsTotal = cards[indexPath.Row].totalHobbs; var cash = cards[indexPath.Row].cashSpent; var flighttype = cards[indexPath.Row].flightType; var pilot = cards[indexPath.Row].pilot; var plane = cards[indexPath.Row].planeType; var lease = cards[indexPath.Row].leaseName; String message = string.Format("Date Out = {0} \n " + "Date In = {1} \n" + "Destination = {2} \n" + "Hobbs In = {3} \n" + "Hobbs Out = {4} \n" + "Total Hobbs = {5}\n " + "Cash Spent = {6} \n" + "Flight Type = {7} \n" + "Pilot = {8}\n" + "Plane = {9}\n" + "Lease = {10} \n", dateOut, dateIn, destination, hobbsIn, hobbsOut, hobbsTotal, cash, flighttype, pilot, plane, lease); String body = message + passString; mailController = new MFMailComposeViewController(); mailController.SetToRecipients(new string[] { "*****@*****.**" }); mailController.SetSubject("Flight Card"); mailController.SetMessageBody("Flight card information: \n " + body, false); mailController.Finished += (object s, MFComposeResultEventArgs args) => { Console.WriteLine(args.Result.ToString()); args.Controller.DismissViewController(true, null); }; vc.PresentViewController(mailController, true, null); } })); actionSheetAlert.AddAction(UIAlertAction.Create("Edit", UIAlertActionStyle.Default, (obj) => { DataManip.SetIsUpdate(true); DataManip.SetEditCard(cards[indexPath.Row]); UIStoryboard board = UIStoryboard.FromName("Main", null); UIViewController ctrl = (UIViewController)board.InstantiateViewController("Add"); ctrl.ModalTransitionStyle = UIModalTransitionStyle.FlipHorizontal; vc.PresentViewController(ctrl, true, null); })); actionSheetAlert.AddAction(UIAlertAction.Create("Delete", UIAlertActionStyle.Default, (obj) => { DataManip.deleteRecordFromFlightCards(cards[indexPath.Row]); cards.RemoveAt(indexPath.Row); tableView.DeleteRows(new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade); })); actionSheetAlert.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, (obj) => {})); vc.PresentViewController(actionSheetAlert, true, null); tableView.DeselectRow(indexPath, true); break; case UITableViewCellEditingStyle.None: Console.WriteLine("commit editing style none called"); break; } }
public override void ViewDidAppear(bool animated) { db = new DataManip(); var cards = new List <FlightCards>(); vc = this; var tapOutside = new UITapGestureRecognizer(() => View.EndEditing(true)); tapOutside.CancelsTouchesInView = false; View.AddGestureRecognizer(tapOutside); Picker(StartRangeTextField); if (Reachability.IsHostReachable("http://www.google.com")) { db.QueryUpdateTables(); db.updateLocalFromRemote(); db.updatePilotFromRemote(); db.updatePlaneFromRemote(); db.updateLeaseFromRemote(); cards = db.LoadArray(startRange); } else { cards = db.LoadArray(startRange); try { Reachability.ReachabilityChanged += delegate { if (Reachability.IsHostReachable("https://www.google.com")) { db.QueryUpdateTables(); db.updateLocalFromRemote(); db.updatePilotFromRemote(); db.updatePlaneFromRemote(); db.updateLeaseFromRemote(); cards = db.LoadArray(startRange); ToastIOS.Toast.MakeText("Host online, Syncing with remote database", ToastIOS.Toast.LENGTH_LONG).Show(); } }; } catch (Exception e) { Console.Out.WriteLine(e.ToString()); } } db = new DataManip(); FlightTableView.Source = new FlightTVS(cards, this); FlightTableView.RowHeight = 150f; FlightTableView.EstimatedRowHeight = 150f; FlightTableView.ReloadData(); refreshControl = new UIRefreshControl(); FlightTableView.AddSubview(refreshControl); refreshControl.ValueChanged += refreshTable; }
public override void ViewDidAppear(bool animated) { base.ViewDidAppear(animated); passengerList = new List <string>(); passengerList = DataManip.returnPassengerList(); }