示例#1
0
        public async Task <IActionResult> PutCarpoolOffer([FromRoute] int id, [FromBody] CarpoolOffer carpoolOffer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != carpoolOffer.CarpoolOfferId)
            {
                return(BadRequest());
            }

            _context.Entry(carpoolOffer).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CarpoolOfferExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#2
0
        public async Task <bool> CreateNewCarpoolOffer(CarpoolOffer carpoolOffer)
        {
            var uri = new Uri(string.Format(AppServerConstants.CarpoolOffersUrl, string.Empty));
            HttpResponseMessage responseMessage = null;

            try
            {
                var json    = JsonConvert.SerializeObject(carpoolOffer);
                var content = new StringContent(json, Encoding.UTF8, "application/json");

                responseMessage = await client.PostAsync(uri, content);

                if (responseMessage.IsSuccessStatusCode)
                {
                    Debug.WriteLine("POST 201 OK: Carpool offer successfully submitted");
                    return(true);
                }
                else
                {
                    Debug.WriteLine(@"POST {0} NOT OK: Carpool offer failed", responseMessage.StatusCode);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"ERROR: {0}", ex.Message);
            }

            return(false);
        }
示例#3
0
        public CPSelectedPage(CarpoolOffer carpoolOffer)
        {
            InitializeComponent();

            BindingContext = carpoolOffer;

            FullName.Text = string.Format("{0} {1}", carpoolOffer.Driver.FirstName, carpoolOffer.Driver.LastName);
        }
示例#4
0
        public async Task <IActionResult> PostCarpoolOffer([FromBody] CarpoolOffer carpoolOffer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.CarpoolOffers.Add(carpoolOffer);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCarpoolOffer", new { id = carpoolOffer.CarpoolOfferId }, carpoolOffer));
        }
示例#5
0
        private async void OfferCarpoolBtn_Clicked(object sender, EventArgs e)
        {
            string confirmBookingText = string.Format("Do you wish to confirm your carpool offer as follows:\n\nDriving From: {0}\nDriving To: {1}\nDeparting Date: {2:D}\nDeparting Time: {3}\nNo. of Seats: {4}\nLadies Only?: {5}\nAdditional Notes: {6}",
                                                      (DrivingFromPicker.SelectedItem as Location).LocationName,
                                                      (DrivingToPicker.SelectedItem as Location).LocationName,
                                                      DepartingDatePicker.Date.ToString("ddd, d MMM yyyy"),
                                                      DateTime.Today.Add(DepartingTimePicker.Time).ToString("h:mm tt"),
                                                      NoOfSeatsPicker.SelectedItem,
                                                      LadiesOnlyPicker.SelectedItem,
                                                      AdditionalNotesEditor.Text);

            bool confirmBooking = await DisplayAlert("Offer Carpool", confirmBookingText, "Yes", "No");

            if (confirmBooking)
            {
                DateTime dateTime = DepartingDatePicker.Date + DepartingTimePicker.Time;

                CarpoolOffer carpoolOffer = new CarpoolOffer
                {
                    DestinationLocationId = (DrivingToPicker.SelectedItem as Location).LocationId,
                    OriginLocationId      = (DrivingFromPicker.SelectedItem as Location).LocationId,
                    OriginDateTime        = dateTime,
                    NoOfPassengers        = Convert.ToInt32(NoOfSeatsPicker.SelectedItem),
                    IsLadiesOnly          = (LadiesOnlyPicker.SelectedItem.Equals("Yes")) ? true : false,
                    AdditionalNotes       = AdditionalNotesEditor.Text,
                    DriverId = App.CurrentDriver.DriverId
                };

                bool IsSubmitted = await App.CarpoolManager.CreateNewCarpoolOffer(carpoolOffer);

                if (IsSubmitted)
                {
                    await DisplayAlert("Offer Carpool", "Your carpool offer is being processed. You will be notified once it is accepted by any of our passengers.", "OK");
                }
                else
                {
                    await DisplayAlert("Offer Carpool", "Your carpool offer could not be processed. Please contact technical support.", "OK");
                }
            }
            else
            {
                await DisplayAlert("Offer Carpool", "You have not proceeded with your carpool offer.", "OK");
            }

            await Navigation.PopToRootAsync();
        }
示例#6
0
        public async Task <CarpoolOffer> GetCarpoolOfferById(int carpoolOfferId)
        {
            CarpoolOffer carpoolOffer = new CarpoolOffer();

            var uri = new Uri(string.Format(AppServerConstants.CarpoolOffersUrl, carpoolOfferId));

            try
            {
                var response = await client.GetAsync(uri);

                if (response.IsSuccessStatusCode)
                {
                    var content = await response.Content.ReadAsStringAsync();

                    carpoolOffer = JsonConvert.DeserializeObject <CarpoolOffer>(content);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(@"ERROR: {0}", ex.Message);
            }

            return(carpoolOffer);
        }
示例#7
0
 public Task <bool> CreateNewCarpoolOffer(CarpoolOffer carpoolOffer)
 {
     return(carpoolService.CreateNewCarpoolOffer(carpoolOffer));
 }