示例#1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.transaction_table = Transaction_Table.GetTransactionById(App.transaction_table.Transaction_Id);

            txtusername.Text = App.user.F_Name + " " + App.user.L_Name;

            if (App.transaction_table != null)
            {
                current_transaction = App.transaction_table;

                if (current_transaction.Volunteer_Id != null)
                {
                    current_volunteer = Volunteer.Get_VolunteerById(current_transaction.Volunteer_Id ?? default(int));

                    txtvolname.Text = current_volunteer.F_Name + " " + current_volunteer.L_Name;

                    if (current_transaction.Driver_Id != null)
                    {
                        current_driver = Driver.Get_DriverById(current_transaction.Driver_Id ?? default(int));

                        txtdriname.Text = current_driver.F_Name + " " + current_driver.L_Name;
                    }
                }
            }
            else
            {
                var dialog = new MessageDialog("Volunteer Has Cancelled the Session");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(UserHome));
            }
        }
        public IHttpActionResult GetTransaction_TableByUser(int id)
        {
            Transaction_Table transaction_Table = db.Transaction_Table.Where(x => x.User_Id == id && (x.Status == "Volunteer Requested" || x.Status == "Active" || x.Status == "Driver Requested")).FirstOrDefault();

            if (transaction_Table == null)
            {
                return(NotFound());
            }

            DTO_Transaction_Table dtt = new DTO_Transaction_Table();

            transaction_Table.ConvertToDTO(dtt);


            if (transaction_Table.User_Id != null)
            {
                User user = db.Users.Where(x => x.User_Id == dtt.User_Id).Single();
                dtt.User_Name          = user.F_Name + " " + user.L_Name;
                dtt.User_Mobile_Number = user.Mobile_Number;
            }
            if (transaction_Table.Volunteer_Id != null)
            {
                Volunteer volunteer = db.Volunteers.Where(x => x.Volunteer_Id == dtt.Volunteer_Id).Single();
                dtt.Volunteer_Name   = volunteer.F_Name + " " + volunteer.L_Name;
                dtt.Volunteer_Mobile = volunteer.Mobile_Number;
            }
            if (transaction_Table.Driver_Id != null)
            {
                Driver driver = db.Drivers.Where(x => x.Driver_Id == dtt.Driver_Id).Single();
                dtt.Driver_Name   = driver.F_Name + " " + driver.L_Name;
                dtt.Driver_Mobile = driver.Mobile_Number;
            }
            return(Ok(dtt));
        }
        public IHttpActionResult GetTransaction_Table(int id)
        {
            Transaction_Table transaction_Table = db.Transaction_Table.Find(id);

            if (transaction_Table == null)
            {
                return(NotFound());
            }

            DTO_Transaction_Table dtt = new DTO_Transaction_Table();

            transaction_Table.ConvertToDTO(dtt);

            if (transaction_Table.User_Id != null)
            {
                User user = db.Users.Where(x => x.User_Id == dtt.User_Id).Single();
                dtt.User_Name          = user.F_Name + " " + user.L_Name;
                dtt.User_Mobile_Number = user.Mobile_Number;
            }
            if (transaction_Table.Volunteer_Id != null)
            {
                Volunteer volunteer = db.Volunteers.Where(x => x.Volunteer_Id == dtt.Volunteer_Id).Single();
                dtt.Volunteer_Name   = volunteer.F_Name + " " + volunteer.L_Name;
                dtt.Volunteer_Mobile = volunteer.Mobile_Number;
            }
            if (transaction_Table.Driver_Id != null)
            {
                Driver driver = db.Drivers.Where(x => x.Driver_Id == dtt.Driver_Id).Single();
                dtt.Driver_Name   = driver.F_Name + " " + driver.L_Name;
                dtt.Driver_Mobile = driver.Mobile_Number;
            }
            return(Ok(dtt));
        }
示例#4
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.transaction_table = Transaction_Table.GetTransactionById(App.transaction_table.Transaction_Id);

            if (App.transaction_table != null)
            {
                txtusername.Text   = App.transaction_table.User_Name;
                txtusermobile.Text = App.transaction_table.User_Mobile_Number;
                txtitems.Text      = App.transaction_table.Items;

                txtvolname.Text   = App.transaction_table.Volunteer_Name;
                txtvolmobile.Text = App.transaction_table.Volunteer_Mobile;


                SetMap();
            }
            else
            {
                var dialog = new MessageDialog("Session has been cancelled");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(DriverHome));
            }
        }
示例#5
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            List <Transaction_Table> list = Transaction_Table.Get_Transactions("driver");

            requests = new ObservableCollection <Transaction_Table>(list);

            lb_Requests.ItemsSource = requests;
        }
示例#6
0
        private void CanSession_Click(object sender, RoutedEventArgs e)
        {
            current_transaction.Status     = "Cancelled";
            current_transaction.Time_Close = System.DateTime.Now;
            Log_Table log = new Log_Table(current_transaction);

            log.Insert();
            Transaction_Table.Delete(current_transaction.Transaction_Id);

            this.Frame.Navigate(typeof(UserCancelFeedback));
        }
        private void CanSession_Click(object sender, RoutedEventArgs e)
        {
            App.transaction_table.Status     = "Cancelled";
            App.transaction_table.Time_Close = System.DateTime.Now;
            Log_Table log = new Log_Table(App.transaction_table);

            log.Insert();
            Transaction_Table.Delete(App.transaction_table.Transaction_Id);

            this.Frame.Navigate(typeof(VolunteerHome));
        }
        public IHttpActionResult PostTransaction_Table(Transaction_Table transaction_Table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Transaction_Table.Add(transaction_Table);
            db.SaveChanges();

            return(CreatedAtRoute("route1", new { id = transaction_Table.Transaction_Id }, transaction_Table));
        }
        public IHttpActionResult DeleteTransaction_Table(int id)
        {
            Transaction_Table transaction_Table = db.Transaction_Table.Find(id);

            if (transaction_Table == null)
            {
                return(NotFound());
            }

            db.Transaction_Table.Remove(transaction_Table);
            db.SaveChanges();

            return(Ok(transaction_Table));
        }
示例#10
0
        private void Continue_Click(object sender, RoutedEventArgs e)
        {
            if (ItemsValid())
            {
                App.transaction_table            = new Transaction_Table();
                App.transaction_table.User_Id    = App.user.User_Id;
                App.transaction_table.Time_Begin = System.DateTime.Now;
                App.transaction_table.Status     = "Volunteer Requested";

                string latitude      = coordinate.Coordinate.Latitude.ToString();
                string longitude     = coordinate.Coordinate.Longitude.ToString();
                int    lat_dec_index = latitude.IndexOf(".");
                int    lon_dec_index = longitude.IndexOf(".");
                App.transaction_table.L_User = latitude.Substring(0, lat_dec_index + 4) + "," + longitude.Substring(0, lon_dec_index + 4);
                App.transaction_table.Insert();

                App.transaction_table = Transaction_Table.GetTransactionByUserId(App.user.User_Id);

                this.Frame.Navigate(typeof(UserSession));
            }
        }
        public IHttpActionResult PutTransaction_Table(int id, Transaction_Table transaction_Table)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != transaction_Table.Transaction_Id)
            {
                return(BadRequest());
            }

            //List<Transaction_Table> list = db.Transaction_Table.ToList();

            //if (list.Exists(x => x.Transaction_Id == transaction_Table.Transaction_Id && x.Status != "Active"))
            //{
            db.Entry(transaction_Table).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Transaction_TableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            //}
            return(StatusCode(HttpStatusCode.NoContent));
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            App.transaction_table = Transaction_Table.GetTransactionById(App.transaction_table.Transaction_Id);

            if (App.transaction_table != null)
            {
                txtusername.Text   = App.transaction_table.User_Name;
                txtusermobile.Text = App.transaction_table.User_Mobile_Number;
                txtitems.Text      = App.transaction_table.Items;

                MapService.ServiceToken = "Ajh0II1uJBt4Y_waGLLyq5R3ftW8N_x1NWUTsXq3m2pInKFpPw6sBctqeDG0RqFI";
                geolocator = new Geolocator();

                coordinate = await geolocator.GetGeopositionAsync();

                // Create a MapIcon.
                MapIcon mapIcon1 = new MapIcon();

                mapIcon1.Location = coordinate.Coordinate.Point;
                mapIcon1.NormalizedAnchorPoint = new Point(0.5, 1.0);
                mapIcon1.Title  = "You";
                mapIcon1.ZIndex = 0;
                MyMap.MapElements.Add(mapIcon1);

                MapIcon mapIcon2 = new MapIcon();

                string[] commapos = App.transaction_table.L_User.Split(",".ToCharArray());
                double   ulat     = double.Parse(commapos[0]);
                double   ulond    = double.Parse(commapos[1]);
                mapIcon2.Location = new Geopoint(new BasicGeoposition {
                    Latitude = ulat, Longitude = ulond
                });
                mapIcon2.NormalizedAnchorPoint = new Point(0.5, 1.0);
                mapIcon2.Title  = "User";
                mapIcon2.ZIndex = 0;

                // Add the MapIcon to the map.
                MyMap.MapElements.Add(mapIcon2);

                await MyMap.TrySetViewAsync(coordinate.Coordinate.Point, 16D);

                BasicGeoposition userlocation = new BasicGeoposition()
                {
                    Latitude = ulat, Longitude = ulond
                };

                // Reverse geocode the specified geographic location.
                MapLocationFinderResult result =
                    await MapLocationFinder.FindLocationsAtAsync(new Geopoint(userlocation));

                // If the query returns results, display the name of the town
                // contained in the address of the first result.
                if (result.Status == MapLocationFinderStatus.Success)
                {
                    txtuseraddress.Text = result.Locations[0].Address.StreetNumber + " " + result.Locations[0].Address.Street + " " + result.Locations[0].Address.Neighborhood + " " + result.Locations[0].Address.Region;
                }

                if (App.transaction_table.Status == "Active" && App.transaction_table.Driver_Id == null)
                {
                    txtdriaddress.Visibility = Visibility.Collapsed;
                    txtdrimobile.Visibility  = Visibility.Collapsed;
                    txtdriname.Visibility    = Visibility.Collapsed;
                    lbldriaddress.Visibility = Visibility.Collapsed;
                    lbldrimobile.Visibility  = Visibility.Collapsed;
                    lbldriname.Visibility    = Visibility.Collapsed;
                }

                if (App.transaction_table.Driver_Id != null)
                {
                    txtdriname.Text   = App.transaction_table.Driver_Name;
                    txtdrimobile.Text = App.transaction_table.Driver_Mobile;

                    MapIcon mapIcon3 = new MapIcon();

                    string[] commapos2 = App.transaction_table.L_Driver.Split(",".ToCharArray());
                    double   dlat      = double.Parse(commapos2[0]);
                    double   dlond     = double.Parse(commapos2[1]);
                    mapIcon3.Location = new Geopoint(new BasicGeoposition {
                        Latitude = dlat, Longitude = dlond
                    });
                    mapIcon3.NormalizedAnchorPoint = new Point(0.5, 1.0);
                    mapIcon3.Title  = "Driver";
                    mapIcon3.ZIndex = 0;

                    // Add the MapIcon to the map.
                    MyMap.MapElements.Add(mapIcon3);

                    BasicGeoposition driverlocation = new BasicGeoposition()
                    {
                        Latitude = dlat, Longitude = dlond
                    };

                    // Reverse geocode the specified geographic location.
                    MapLocationFinderResult dresult =
                        await MapLocationFinder.FindLocationsAtAsync(new Geopoint(driverlocation));

                    // If the query returns results, display the name of the town
                    // contained in the address of the first result.
                    if (dresult.Status == MapLocationFinderStatus.Success)
                    {
                        txtdriaddress.Text = dresult.Locations[0].Address.StreetNumber + " " + dresult.Locations[0].Address.Street + " " + dresult.Locations[0].Address.Neighborhood + " " + dresult.Locations[0].Address.Region;
                    }
                }
            }
            else
            {
                var dialog = new MessageDialog("User Has Cancelled The Session");
                dialog.Commands.Add(new UICommand("OK"));
                await dialog.ShowAsync();

                this.Frame.Navigate(typeof(VolunteerHome));
            }
        }