public IHttpActionResult PutFlightTravellerDetail(int id, FlightTravellerDetail flightTravellerDetail)
        {
            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }*/

            if (id != flightTravellerDetail.TravellerID)
            {
                return(BadRequest());
            }

            db.Entry(flightTravellerDetail).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FlightTravellerDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
        // PUT FlightTravellerDetail
        public async Task UpdateFlightTravellerDetail(int id, FlightTravellerDetail flightTravellerDetail)
        {
            var httpClient = new HttpClient();

            var           json          = JsonConvert.SerializeObject(flightTravellerDetail);
            StringContent stringContent = new StringContent(json);

            stringContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");

            var result = await httpClient.PutAsync(rootUrl + "api/FlightTravellerDetails/" + id, stringContent);
        }
        public IHttpActionResult PostFlightTravellerDetail(FlightTravellerDetail flightTravellerDetail)
        {
            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }*/

            db.FlightTravellerDetails.Add(flightTravellerDetail);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = flightTravellerDetail.TravellerID }, flightTravellerDetail));
        }
        public IHttpActionResult DeleteFlightTravellerDetail(int id)
        {
            FlightTravellerDetail flightTravellerDetail = db.FlightTravellerDetails.Find(id);

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

            db.FlightTravellerDetails.Remove(flightTravellerDetail);
            db.SaveChanges();

            return(Ok(flightTravellerDetail));
        }
Exemplo n.º 5
0
        private async void Submit(object sender, System.EventArgs e)
        {
            flightTraveller = new FlightTravellerDetail
            {
                TravellerID  = 0,
                CustomerID   = Convert.ToInt32(Settings.CustomerID),
                SeatNumber   = null,
                Firstname    = FirstName.Text,
                Lastname     = LastName.Text,
                Dateofbirth  = Settings.Date,
                Gender       = Gender.Text,
                Mobilenumber = MobileNumber.Text,
                Email        = Email.Text
            };

            await flightTravellerService.AddFlightTravellerDetail(flightTraveller);

            await DisplayAlert("Sucessfully save", "", "Ok");
        }