public ActionResult DeleteConfirmed(int id) { ParkedVehicle parkedVehicle = db.ParkedVehicles.Find(id); var kvittoModel = new KvittoViewModel { RegistrationNumber = parkedVehicle.RegistrationNumber, CheckInTime = parkedVehicle.CheckInTime, CheckOutTime = DateTime.Now, ParkingTime = DateTime.Now - parkedVehicle.CheckInTime, Customer = parkedVehicle.Customer.LastName }; db.ParkedVehicles.Remove(parkedVehicle); db.SaveChanges(); //Remove Parking //var removeParkingPlace = parking.GetParkingPlaceId(parkedVehicle.Id); //foreach (var item in removeParkingPlace) //{ // Parking removedVehicle = db.Parkings.Find(item); // db.Parkings.Remove(removedVehicle); //} //db.SaveChanges(); return(RedirectToAction("Kvitto", kvittoModel)); }
// GET: Kvitto public ActionResult PrintableKvitto(string RegistrationNumber, DateTime CheckInTime, DateTime CheckOutTime, TimeSpan ParkingTime, string Customer) { var kvittoModel = new KvittoViewModel { RegistrationNumber = RegistrationNumber, CheckInTime = CheckInTime, CheckOutTime = CheckOutTime, ParkingTime = ParkingTime, Customer = Customer.ToString() }; return(View(kvittoModel)); }
public ActionResult Kvitto(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } IncheckedVehicle incheckedVehicle = db.Vehicles.Find(id); KvittoViewModel kvm = new KvittoViewModel(); double TotalMinutes = DateTime.Now.Subtract(incheckedVehicle.CheckInTime).TotalMinutes; kvm.Time = Math.Ceiling(TotalMinutes / 60); kvm.Cost = kvm.Time * kvm.Price; return(View(kvm)); }
public ActionResult DeleteConfirmed(int?id) { var fordon = db.Fordons //.Include(f => f.Fordonstyper) //.Include(f => f.Medlemmar) .SingleOrDefault(x => x.Id == id); TimeSpan currenttime = (DateTime.Now - fordon.Tid); var kvitto = new KvittoViewModel(); kvitto.Ankomsttid = fordon.Tid; kvitto.Namn = fordon.Medlemmar.FullständigtNamn; kvitto.RegNr = fordon.RegNr; kvitto.Kostnad = (int)currenttime.TotalMinutes; kvitto.Utcheckningstid = DateTime.Now; ViewBag.currenttime = Convert.ToInt32(currenttime.Hours); ViewBag.currentminutes = Convert.ToInt32(currenttime.Minutes); db.Fordons.Remove(fordon); db.SaveChanges(); //return RedirectToAction("Kvito",kvitto); return(View("Kvitto", kvitto)); }
// GET: Kvitto public ActionResult Kvitto(KvittoViewModel Kvitto) { var kvitto = Kvitto; return(View(kvitto)); }