예제 #1
0
        public ActionResult Receipt(Vehicle vehicle)
        {

            DateTime CheckOutTime = DateTime.Now;
            TimeSpan? ParkingTime = new TimeSpan();

            ParkingTime = CheckOutTime - vehicle.CheckInTime;

            double totH = ParkingTime.Value.TotalHours;
            int totHours = Convert.ToInt32(Math.Truncate(totH));

            var result = string.Format("{0:D2}:{1:D2}", totHours, ParkingTime.Value.Minutes);

            double pay = ParkingTime.Value.TotalHours * 60;
            string Payment = String.Format("{0:0}", pay);

            ViewBag.CheckOutTime = CheckOutTime;
            ViewBag.Payment = Payment;
            ViewBag.ParkingTime = result;
            ViewBag.MemberName = db.Members.Where(m => m.Id == vehicle.MemberId).FirstOrDefault().Name;
            ViewBag.VehType = db.VehicleTypes.Where(m => m.Id == vehicle.VTypeId).FirstOrDefault().Type;
            return View(vehicle);

        }
예제 #2
0
        public ActionResult Receipt(Vehicle vehicle)
        { 

            DateTime CheckOutTime = DateTime.Now;
            TimeSpan? ParkingTime = new TimeSpan();

            ParkingTime = CheckOutTime - vehicle.CheckInTime;

            double totH = ParkingTime.Value.TotalHours;
            int totHours = Convert.ToInt32(Math.Truncate(totH));

            var result = string.Format("{0:D2}:{1:D2}", totHours, ParkingTime.Value.Minutes);

            double pay = ParkingTime.Value.TotalHours * 60;
            string Payment = String.Format("{0:0}", pay);

            ViewBag.CheckOutTime = CheckOutTime;
            ViewBag.Payment = Payment;
            ViewBag.ParkingTime = result;

            return View(vehicle);

        }
예제 #3
0
        public bool Register(Vehicle vehicle)
        {
            db.Vehicles.Add(vehicle);
            db.SaveChanges();

            return true;
        }
예제 #4
0
        public ActionResult Receipt(Vehicle vehicle)
        {
            if (vehicle == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            var TimeNow = DateTime.Now;
            ViewBag.DateTime = TimeNow;
            int ParkDay = TimeNow.Day - vehicle.ParkTime.Day;
            int ParkHour = TimeNow.Hour - vehicle.ParkTime.Hour;
            int ParkMinute = TimeNow.Minute - vehicle.ParkTime.Minute;
            int totalMinutes = ParkDay*24*60+ParkHour*60+ParkMinute;
            int ParkNoDays = Convert.ToInt32(totalMinutes/(24*60));
            int RestMinutes = totalMinutes - ParkNoDays * 24 * 60;
            int ParkNoHours = Convert.ToInt32(RestMinutes/60);
            int ParkNoMinutes = RestMinutes - ParkNoHours * 60;

            ViewBag.ParkTime = "Du har parkerat " + ParkNoDays + " days, " +
                ParkNoHours + " hours and " + ParkNoMinutes + " minutes";
            return View(vehicle);
        }