Example #1
0
  //[Authorize]
 // [HttpGet]
 public ActionResult Addvehicle(int id)
 {
     //var model = _ownerService.GetOwner(id);
     //return PartialView("_Addvehicle", model);
     var years = new List<DisplayNameValue>();
     for (int i = 1975; i < DateTime.Now.Year; i++)
     {
         years.Add(new DisplayNameValue
         {
             Name=i.ToString(),
             Id=i.ToString()
         });
     }
     var model = new VehicleViewModel()
     {
         AvailableLocations = _commonService.GetLocations().ToList(),
         AvailableVechicleColors = _commonService.GetVechicleColors().ToList(),
         AvailableVehicleBrands = _commonService.GetVehicleBrands().ToList(),
         AvailableVehicleCategories = _commonService.GetVehicleCategories().ToList(),
         AvailableVehicleDriveTypes = _commonService.GetVehicleDriveTypes().ToList(),
         AvailableVehicleFuelTypes = _commonService.GetVehicleFuelTypes().ToList(),
         AvailableVehicleModels = _commonService.GetVehicleModels().ToList(),
         AvailableVehicleTransmisions = _commonService.GetVehicleTransmisions().ToList(),
         AvailableVehicleTypes = _commonService.GetVehicleTypes().ToList(),
         OwnerId=id,
         Vehicle=new Domain.Entities.Vehicle(),
         Years= years
     }; 
     
     return PartialView("_Addvehicle", model);
 }
Example #2
0
         public ActionResult AddEdit(VehicleViewModel model)
         {
             if (ModelState.IsValid)
             {
                 model.OwnerId = int.Parse(User.Identity.GetUserId());
                 if (_ownerService.AddUpdateVechile(model.Vehicle))
                 {
                     return RedirectToAction("AddEdit", new { id = model.VehicleId });
                 }
             }

             ViewBag.VM = new VehicleViewModel()
             {
                 AvailableLocations = _commonService.GetLocations().ToList(),
                 AvailableVechicleColors = _commonService.GetVechicleColors().ToList(),
                 AvailableVehicleBrands = _commonService.GetVehicleBrands().ToList(),
                 AvailableVehicleCategories = _commonService.GetVehicleCategories().ToList(),
                 AvailableVehicleDriveTypes = _commonService.GetVehicleDriveTypes().ToList(),
                 AvailableVehicleFuelTypes = _commonService.GetVehicleFuelTypes().ToList(),
                 AvailableVehicleModels = _commonService.GetVehicleModels().ToList(),
                 AvailableVehicleTransmisions = _commonService.GetVehicleTransmisions().ToList(),
                 AvailableVehicleTypes = _commonService.GetVehicleTypes().ToList()
             };
             return View(model);
         }