コード例 #1
0
 public ActionResult Edit(Vehicle vehicle)
 {
     if (ModelState.IsValid)
     {
         Garage.UpdateVehicle(vehicle);
         Garage.Save();
         return RedirectToAction("Index");
     }
     return View(vehicle);
 }
コード例 #2
0
 //public IEnumerable<Vehicle> SearchByOwner(string owner, bool today)
 //{
 //    //var result = from v in context.Vehicles
 //    //             where String.Compare(v.Vehicle_OwnerId, owner, StringComparison.InvariantCultureIgnoreCase) == 0
 //    //             select v;
 //    //if (today == true)
 //    //{
 //    //    result = from v in result
 //    //              where v.ParkingIn.Value.Date == DateTime.Today
 //    //              select v;
 //    //}
 //    //return (result);
 //    return null;
 //}
 //public IEnumerable<Vehicle> FilterByType(VehicleType type)
 //{
 //    //var result = from v in context.Vehicles
 //    //             where v.Vehicle_TypeId == type
 //    //             select v;
 //    //return (result);
 //    return null;
 //}
 // Returns all the vehicles to have entered the garage today.
 //public IEnumerable<Vehicle> GetTodaysParking()
 //{
 //    var result = from v in context.Vehicles
 //                 where v.ParkingIn == DateTime.Today
 //                 select v;
 //    return (result);
 //}
 public void UpdateVehicle(Vehicle v)
 {
     context.Entry(v).State = EntityState.Modified;
 }
コード例 #3
0
        public ActionResult Create( Vehicle vehicle)
        {
            if (ModelState.IsValid)
            {
                vehicle.ParkingIn = DateTime.Now;
                vehicle.ParkingOut = DateTime.Now.AddHours(2);
                Garage.InsertVehicle(vehicle);
                Garage.Save();
                return RedirectToAction("Index");
            }

            return View(vehicle);
        }
コード例 #4
0
 //public IEnumerable<Vehicle> GetVehicles(bool? today, FilterType filter = FilterType.All, VehicleType vehicleFilter = VehicleType.Car)
 //{
 //    IEnumerable<Vehicle> results;
 //    switch (filter)
 //    {
 //        case FilterType.All:
 //            {
 //                results = context.Vehicles.ToList();
 //                break;
 //            }
 //        //case FilterType.ByType:
 //        //    {
 //        //        results = from v in context.Vehicles
 //        //                      where vehicleFilter == v.vehicleType
 //        //                      select v;
 //        //        break;
 //        //    }
 //        case FilterType.Today:
 //            {
 //                results = from v in context.Vehicles
 //                             where v.ParkingIn == DateTime.Today
 //                             select v;
 //                break;
 //            }
 //        default:
 //            {
 //                results = context.Vehicles.ToList();
 //            }
 //            break;
 //    }
 //    if(today == true)
 //    {
 //        results = from v in results
 //                  where v.ParkingIn.Value.Date == DateTime.Today
 //                  select v;
 //    }
 //    //var r = results.OrderBy(x => x.vehicleType).ThenByDescending(y => y.ParkingIn);
 //   return ( results);
 //}
 public void InsertVehicle(Vehicle v)
 {
     context.Vehicles.Add(v);
 }