Exemplo n.º 1
0
        public IHttpActionResult PutClient_Flight(Client_Flight client_Flight)
        {
            int id = client_Flight.CF_Id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != client_Flight.CF_Id)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemplo n.º 2
0
 public ClientFlightModel Create(Client_Flight client_flight)
 {
     return(new ClientFlightModel()
     {
         CF_Id = client_flight.CF_Id,
         DateCreated = (DateTime)client_flight.DateCreated,
         Status = client_flight.Status,
         ClientId = (int)client_flight.ClientId,
         FlightId = (int)client_flight.FlightId,
         TotalCost = (float)client_flight.TotalCost
     });
 }
Exemplo n.º 3
0
        public IHttpActionResult PostClient_Flight(Client_Flight client_Flight)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Client_Flight.Add(client_Flight);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = client_Flight.CF_Id }, client_Flight));
        }
Exemplo n.º 4
0
        public IHttpActionResult DeleteClient_Flight(int id)
        {
            Client_Flight client_Flight = db.Client_Flight.Find(id);

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

            db.Client_Flight.Remove(client_Flight);
            db.SaveChanges();

            return(Ok(client_Flight));
        }
Exemplo n.º 5
0
 public ClientFlightModel Create(Client_Flight client_flight)
 {
     return(new ClientFlightModel()
     {
         CF_Id = client_flight.CF_Id,
         DateCreated = (DateTime)client_flight.DateCreated,
         Status = client_flight.Status,
         ClientId = (int)client_flight.ClientId,
         FlightId = (int)client_flight.FlightId,
         TotalCost = (float)client_flight.TotalCost,
         FlightPayment = client_flight.FlightPayments.Select(fp => Create(fp)),
         ArrivalLocation = client_flight.Flight.ArrivalLocation,
         DepartureLocation = client_flight.Flight.DepartureLocation,
         ArrivalTime = client_flight.Flight.ArrivalTime,
         DepartureTime = client_flight.Flight.DepartureTime
     });
 }