public async Task <IActionResult> DeleteConfirmed(int id)
        {
            FlatParkingRate flatParkingRate = _repository.GetFlatParkingRateByID((int)id);  // await db.FlatParkingRates.FindAsync(id);

            _repository.DeleteFlatParkingRate(id);
            return(RedirectToAction("Index"));
        }
예제 #2
0
        public void CreateNewFlatParkingRate(FlatParkingRate flatParkingRate)
        {
            if (ExceptionToThrow != null)
            {
                throw ExceptionToThrow;
            }

            _db.Add(flatParkingRate);
        }
 public async Task <IActionResult> Edit([Bind(include: "ID, Description, EntryTimeStart, EntryTimeEnd, ExitTimeStart, ExitTimeEnd, EntryDays, Charge")] FlatParkingRate flatParkingRate)
 {
     if (ModelState.IsValid)
     {
         _repository.UpdateFlatParkingRate(flatParkingRate);
         return(RedirectToAction("Index"));
     }
     return(View(flatParkingRate));
 }
예제 #4
0
 public void SaveChanges(FlatParkingRate flatParkingRate)
 {
     foreach (var rate in _db)
     {
         if (rate.ID == flatParkingRate.ID)
         {
             _db.Remove(flatParkingRate);
             _db.Add(flatParkingRate);
             break;
         }
     }
 }
        // GET: FlatParkingRates/Delete/5
        public async Task <IActionResult> Delete(int?id)
        {
            if (id == null)
            {
                return(new BadRequestResult());
            }
            FlatParkingRate flatParkingRate = _repository.GetFlatParkingRateByID((int)id);  //  await db.FlatParkingRates.FindAsync(id);

            if (flatParkingRate == null)
            {
                return(new NotFoundResult());
            }
            return(View(flatParkingRate));
        }
 public void UpdateFlatParkingRate(FlatParkingRate flatParkingRate)
 {
     _context.FlatParkingRates.Update(flatParkingRate);
     _context.SaveChanges();
 }
 public void CreateNewFlatParkingRate(FlatParkingRate flatParkingRate)
 {
     _context.FlatParkingRates.Add(flatParkingRate);
     _context.SaveChanges();
 }
예제 #8
0
 public void UpdateFlatParkingRate(FlatParkingRate flatParkingRate)
 {
     SaveChanges(flatParkingRate);
 }
예제 #9
0
 public void Add(FlatParkingRate flatParkingRate)
 {
     _db.Add(flatParkingRate);
 }
예제 #10
0
        public static void Initialise(ParkingAppContext context)
        {
            context.Database.EnsureCreated();

            if (!context.FlatParkingRates.Any())
            {
                var flatParkingRates = new FlatParkingRate[]
                {
                    new FlatParkingRate
                    {
                        Description    = "Early Bird",
                        EntryTimeStart = TimeSpan.Parse("06:00"),
                        EntryTimeEnd   = TimeSpan.Parse("09:00"),
                        ExitTimeStart  = TimeSpan.Parse("15:30"),
                        ExitTimeEnd    = TimeSpan.Parse("23:30"),
                        EntryDays      = 62,
                        Charge         = 13.00m
                    },
                    new FlatParkingRate
                    {
                        Description    = "Night Rate",
                        EntryTimeStart = TimeSpan.Parse("18:00"),
                        EntryTimeEnd   = TimeSpan.Parse("1.00:00"),
                        ExitTimeStart  = TimeSpan.Parse("18:00"),
                        ExitTimeEnd    = TimeSpan.Parse("1.06:00"),
                        EntryDays      = 62,
                        Charge         = 6.50m
                    },
                    new FlatParkingRate
                    {
                        Description    = "Weekend Rate",
                        EntryTimeStart = TimeSpan.Parse("00:00"),
                        EntryTimeEnd   = TimeSpan.Parse("2.00:00"),
                        ExitTimeStart  = TimeSpan.Parse("00:00"),
                        ExitTimeEnd    = TimeSpan.Parse("2.00:00"),
                        EntryDays      = 64,
                        Charge         = 10.00m
                    },
                    new FlatParkingRate
                    {
                        Description    = "Weekend Rate",
                        EntryTimeStart = TimeSpan.Parse("00:00"),
                        EntryTimeEnd   = TimeSpan.Parse("1.00:00"),
                        ExitTimeStart  = TimeSpan.Parse("00:00"),
                        ExitTimeEnd    = TimeSpan.Parse("1.00:00"),
                        EntryDays      = 1,
                        Charge         = 10.00m
                    },
                };
                foreach (var rate in flatParkingRates)
                {
                    context.FlatParkingRates.Add(rate);
                }
                context.SaveChanges();
            }

            if (!context.HourlyRates.Any())
            {
                var hourlyRates = new HourlyRate[]
                {
                    new HourlyRate {
                        HourLimit = 1, Charge = 5.00m
                    },
                    new HourlyRate {
                        HourLimit = 2, Charge = 10.00m
                    },
                    new HourlyRate {
                        HourLimit = 3, Charge = 15.00m
                    },
                };
                foreach (var rate in hourlyRates)
                {
                    context.HourlyRates.Add(rate);
                }
                context.SaveChanges();
            }

            if (!context.DailyRates.Any())
            {
                var dailyRate = new DailyRate {
                    Charge = 20.00m
                };
                context.DailyRates.Add(dailyRate);
                context.SaveChanges();
            }
        }
예제 #11
0
 public void MarkAsModified(FlatParkingRate rate)
 {
 }