public ReceiptViewModel(ViewModels.CheckOutViewModel vehicle) { RegNo = vehicle.RegNo; Owner = vehicle.Member; CheckInTime = vehicle.CheckInTime; CheckOutTime = (DateTime)vehicle.CheckOutTime; }
public ActionResult ConfirmCheckOut(int id) { ParkedVehicle vehicleDetail = db.ParkedVehicle.FirstOrDefault(v => v.Id == id); double pricePerHour = db.Garage.FirstOrDefault().PricePerHour; vehicleDetail.TotalPrice = TotalPrice(vehicleDetail.CheckInTime, DateTime.Now, pricePerHour); if (vehicleDetail == null) { ModelState.AddModelError("RegNo", "Registreringsnumret hittades inte"); } if (ModelState.IsValid) { ViewBag.AskForRegNo = false; ViewBag.ConfirmedCheckOut = true; ViewBag.checkedOut = false; var checkOutViewModel = new ViewModels.CheckOutViewModel(vehicleDetail); return(View("CheckOut", checkOutViewModel)); } ViewBag.AskForRegNo = true; ViewBag.ConfirmedCheckOut = false; ViewBag.checkedOut = false; return(View("CheckOut")); }
public ActionResult Receipt(ViewModels.CheckOutViewModel checkedOutVehicle) { var receiptVehicle = new ViewModels.ReceiptViewModel(checkedOutVehicle); double pricePerHour = db.Garage.FirstOrDefault().PricePerHour; receiptVehicle.PricePerHour = string.Format("{0:F2} kr", pricePerHour); receiptVehicle.TotalPrice = TotalPriceString(receiptVehicle.CheckInTime, receiptVehicle.CheckOutTime, pricePerHour); receiptVehicle.TimeParked = TimeParkedLongString(receiptVehicle.CheckInTime, receiptVehicle.CheckOutTime); return(View(receiptVehicle)); }
public ActionResult CheckOut(int?id) { ViewBag.AskForRegNo = true; ViewBag.ConfirmedCheckOut = false; ViewBag.checkedOut = false; if (id != null) { ParkedVehicle vehicleDetail = db.ParkedVehicle.FirstOrDefault(v => v.Id == id); if (vehicleDetail == null) { return(HttpNotFound()); } var checkOutViewModel = new ViewModels.CheckOutViewModel(vehicleDetail); return(View(checkOutViewModel)); } return(View()); }
public ActionResult CheckOutConfirmed(int id)//string RegNo) { ViewBag.AskForRegNo = false; ParkedVehicle vehicleDetail = db.ParkedVehicle.FirstOrDefault(v => v.Id == id); vehicleDetail.CheckOutTime = DateTime.Now; double pricePerHour = db.Garage.FirstOrDefault().PricePerHour; vehicleDetail.TotalPrice = TotalPrice(vehicleDetail.CheckInTime, (DateTime)vehicleDetail.CheckOutTime, pricePerHour); var checkOutViewModel = new ViewModels.CheckOutViewModel(vehicleDetail); db.ParkedVehicle.Remove(vehicleDetail); db.SaveChanges(); ViewBag.checkedOut = true; return(View("CheckOut", checkOutViewModel)); }