public ActionResult SeeInvoice() { TotalHoursViewModel model = new TotalHoursViewModel(); Invoice NewInvoice = new Invoice(); string currentUser = User.Identity.GetUserId(); List <Flight> FlightList = db.Flights.Where(x => x.UserId == currentUser).ToList(); PreFlight PreFlights = new PreFlight(); PostFlight PostFlights = new PostFlight(); double totalHoursFlown; double GrandTotal = 0; for (int i = 0; i < FlightList.Count; i++) { var flightId = FlightList[i].FlightId; var PreF = db.PreFlights.Where(x => (int)x.FlightIdentification == flightId).Select(x => x.StartingHobbsHours).FirstOrDefault(); var PostF = db.PostFlights.Where(x => (int)x.FlightIdentification == flightId).Select(x => x.EndingHobbsHours).FirstOrDefault(); totalHoursFlown = PostF - PreF; GrandTotal += totalHoursFlown; } NewInvoice.HoursFlown = GrandTotal; NewInvoice.HourlyFlightRate = 75.00; NewInvoice.HoursBilled = GrandTotal * NewInvoice.HourlyFlightRate; NewInvoice.MonthlyDues = 130.00; NewInvoice.TotalAmountOwed = NewInvoice.MonthlyDues + NewInvoice.HoursBilled; var stripePublishKey = "PUBLICKEYHERE"; ViewBag.StripePublishKey = stripePublishKey; return(View(NewInvoice)); }
public ActionResult DeleteConfirmed(int id) { PostFlight postFlight = db.PostFlights.Find(id); db.PostFlights.Remove(postFlight); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "PostFlightId,FlightIdentification,EndingEngineHours,EndingHobbsHours,Squawks,SplitTime,SplitTimePilotId")] PostFlight postFlight) { if (ModelState.IsValid) { db.Entry(postFlight).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Flight = new SelectList(db.Flights, "FlightId", "Destination", postFlight.FlightIdentification); return(View(postFlight)); }
// GET: PostFlights/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PostFlight postFlight = db.PostFlights.Find(id); if (postFlight == null) { return(HttpNotFound()); } return(View(postFlight)); }
// GET: PostFlights/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PostFlight postFlight = db.PostFlights.Find(id); if (postFlight == null) { return(HttpNotFound()); } ViewBag.Flight = new SelectList(db.Flights, "FlightId", "Destination", postFlight.FlightIdentification); return(View(postFlight)); }
public ActionResult PostFlight(PostFlightViewModel model) { PostFlight postFlight = new PostFlight(); List <Flight> ListOfFlights = db.Flights.ToList(); var FlightNumber = ListOfFlights[ListOfFlights.Count - 1].FlightId; postFlight.FlightIdentification = FlightNumber; postFlight.EndingEngineHours = model.postModel.EndingEngineHours; postFlight.EndingHobbsHours = model.postModel.EndingHobbsHours; postFlight.Squawks = model.postModel.Squawks; postFlight.SplitTime = model.postModel.SplitTime; postFlight.SplitTimePilotId = model.postModel.SplitTimePilotId; db.PostFlights.Add(postFlight); db.SaveChanges(); return(RedirectToAction("Index", "Home")); }