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 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 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 IHttpActionResult GetCancel(int BookingID) { Cancellation cancel = new Cancellation(); cancel.BookingID = BookingID; cancel.CancellationDate = DateTime.Now; cancel.FlightID = db.Bookings.Where(b => b.BookingID == BookingID).ToList()[0].FlightID; int BookingPrice = db.Bookings.Where(b => b.BookingID == BookingID).ToList()[0].BookingAmount; cancel.RefundAmount = BookingPrice - (int)(BookingPrice * 0.2); db.Cancellations.Add(cancel); db.SaveChanges(); return(Ok(new { message = "Success", RefundAmount = cancel.RefundAmount })); }
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 dynamic UpdatePassword(string email, string password) { //var query = from user in tblUser where user.email == email select user; //var query = db.Customers.Find(email); List <RegisteredUser> emp = db.RegisteredUsers.ToList(); foreach (var item in emp) { if (item.Email == email) { item.Password = password; //item.ConfirmPassword = password; db.Entry(item).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(Request.CreateResponse(HttpStatusCode.OK, "Valid")); } } return(Request.CreateResponse(HttpStatusCode.NotFound, "NotFound")); }
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." }); }