public HttpResponseMessage PostLogin(string email, string password) { FRSEntities db = new FRSEntities(); bool Exists = false; RegisteredUser ru = new RegisteredUser(); List <RegisteredUser> users = db.RegisteredUsers.ToList(); foreach (var item in users) { if (item.Email == email) { Exists = true; ru = item; break; } } if (Exists) { if (ru.Password == password) { return(Request.CreateResponse(HttpStatusCode.OK, "Success")); } else { return(Request.CreateResponse(HttpStatusCode.OK, "Wrong Password")); } } else { return(Request.CreateResponse(HttpStatusCode.OK, "Invalid User")); } }
public object createcontact(Registration Lvm) { try { FRSEntities db = new FRSEntities(); RegisteredUser Ru = new RegisteredUser(); if (Ru.Email == null) { Ru.FirstName = Lvm.FirstName; Ru.LastName = Lvm.LastName; Ru.Email = Lvm.Email; Ru.Password = Lvm.Password; Ru.DOB = Lvm.DOB; Ru.ContactNo = Lvm.ContactNo; Ru.Title = Lvm.Title; db.RegisteredUsers.Add(Ru); db.SaveChanges(); return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public object createclass(AddClass Lvm) { try { FRSEntities db = new FRSEntities(); Class Ru = new Class(); if (Ru.ClassID == 0) { Ru.ClassID = Lvm.ClassID; Ru.FlightID = Lvm.FlightID; Ru.BusinessCost = Lvm.BusinessCost; Ru.NoOfBusinessSeats = Lvm.NoOfBusinessSeats; Ru.EconomyCost = Lvm.EconomyCost; Ru.NoOfEconomySeats = Lvm.NoOfEconomySeats; db.Classes.Add(Ru); db.SaveChanges(); return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public object createflight(AddFlight Lvm) { try { FRSEntities db = new FRSEntities(); Flight Ru = new Flight(); if (Ru.FlightID == 0) { Ru.SourceFlight = Lvm.SourceFlight; Ru.Destination = Lvm.Destination; Ru.ArrivalTime = Lvm.ArrivalTime; Ru.DepartureTime = Lvm.DepartureTime; Ru.NoOfSeats = Lvm.NoOfSeats; Ru.FlightDate = Lvm.FlightDate; Ru.Duration = Lvm.Duration; Ru.Del = 1; Ru.SeatAvailability = 60; db.Flights.Add(Ru); db.SaveChanges(); return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public object createclass(AddPassenger Lvm) { try { FRSEntities db = new FRSEntities(); Passenger Ru = new Passenger(); if (Ru.PassengerID == 0) { Ru.FirstName = Lvm.FirstName; Ru.LastName = Lvm.LastName; Ru.Age = Lvm.Age; Ru.BookingID = Lvm.BookingID; Ru.Email = Lvm.Email; Ru.SeatID = Lvm.SeatID; db.Passengers.Add(Ru); db.SaveChanges(); return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public object cancel(Cancel Lvm) { try { FRSEntities db = new FRSEntities(); Cancellation c = new Cancellation(); if (c.CancellationID == 0) { c.CancellationDate = Lvm.CancellationDate; c.FlightID = Lvm.FlightID; c.RefundAmount = Lvm.RefundAmount; c.BookingID = Lvm.BookingID; db.Cancellations.Add(c); db.SaveChanges(); return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }
public IHttpActionResult GetLastFlight() { FRSEntities db = new FRSEntities(); List <Flight> countrylist = new List <Flight>(); var country = db.Flights.OrderByDescending(p => p.FlightID).FirstOrDefault().FlightID; return(Ok(country)); }
public IHttpActionResult GetFlight(int id) { FRSEntities db = new FRSEntities(); List <Flight> countrylist = new List <Flight>(); var country = db.Flights.Where(p => p.FlightID == id).FirstOrDefault().FlightDate; return(Ok(country)); }
public IHttpActionResult GetBooingAmount(int id) { FRSEntities db = new FRSEntities(); List <Booking> flights = db.Bookings.ToList(); var amount = db.Bookings.Where(c => c.BookingID == id).FirstOrDefault().BookingAmount; return(Ok(amount)); }
public IHttpActionResult GetLastBooking() { FRSEntities db = new FRSEntities(); List <Booking> bookings = new List <Booking>(); var bid = db.Bookings.OrderByDescending(p => p.BookingID).FirstOrDefault().BookingID; return(Ok(bid)); }
public IHttpActionResult GetClass(int id) { FRSEntities db = new FRSEntities(); List <Class> countrylist = new List <Class>(); //var exists = countrylist.Find(p => p.FlightID == id); //if (countrylist.Exists(p => p.FlightID == id)) ecost = db.Classes.Where(p => p.FlightID == id).First().ClassID; return(Ok(ecost)); }
public IHttpActionResult GetEconomyCost(int id) { FRSEntities db = new FRSEntities(); List <Class> countrylist = new List <Class>(); var cost = db.Classes.Where(s => s.FlightID == id).First().EconomyCost; if (cost == 0) { return(NotFound()); } return(Ok(cost)); }
public HttpResponseMessage Delete(int id) { FRSEntities db = new FRSEntities(); try { Flight flight = db.Flights.Where(q => q.FlightID == id).FirstOrDefault(); flight.Del = 0; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Successful Deletion")); } catch { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Unsuccessful")); } }
public void Put(int id, [FromUri] Flight f) { try { FRSEntities db = new FRSEntities(); Booking booking = new Booking(); //int count; f = (from p in db.Flights where p.FlightID == id select p).SingleOrDefault(); booking = (from p in db.Bookings where p.FlightID == id select p).OrderByDescending(b => b.BookingID).ToList()[0]; f.SeatAvailability = f.SeatAvailability - booking.NoofTickets; db.SaveChanges(); } catch (Exception e) { Ok(e.Message); } }
public object createbooking(AddBooking Lvm) { try { FRSEntities db = new FRSEntities(); Booking Ru = new Booking(); if (Ru.BookingID == 0) { Ru.FlightID = Lvm.FlightID; Ru.Email = Lvm.Email; Ru.ClassID = Lvm.ClassID; Ru.BookingDate = Lvm.BookingDate; Ru.NoofTickets = Lvm.NoofTickets; Ru.BookingAmount = Lvm.BookingAmount; Ru.DateOfDeparture = Lvm.DateOfDeparture; Ru.ReturnDate = Lvm.ReturnDate; Ru.ReturnTicket = Lvm.ReturnTicket; Ru.ClassDetails = Lvm.ClassDetails; Ru.Del = 1; db.Bookings.Add(Ru); db.SaveChanges(); return(new Response { Status = "Success", Message = "SuccessFully Saved." }); } } catch (Exception) { throw; } return(new Response { Status = "Error", Message = "Invalid Data." }); }