Пример #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Vehicle vehicle = db.Vehicles.Find(id);


            var receipt = new ReceiptModelView();

            receipt.LicensePlate = vehicle.LicensePlate;
            receipt.CheckInTime  = vehicle.CheckInTime;
            receipt.CheckOutTime = DateTime.Now;
            receipt.Owner        = vehicle.Owner?.Name;
            receipt.ParkDuration = receipt.CheckOutTime - receipt.CheckInTime;
            receipt.Price        = receipt.ParkDuration.TotalHours * 20;

            db.Vehicles.Remove(vehicle);
            db.SaveChanges();

            return(RedirectToAction("Receipt", receipt));
        }
Пример #2
0
 public ActionResult Receipt(ReceiptModelView receipt)
 {
     return(View(receipt));
 }