예제 #1
0
        public ActionResult CreateVehicle(Guid? id)
        {
            var viewmodel = new VehicleViewModel();
            if (id.HasValue)
            {
                viewmodel = _vehicleViewModelBuilder.Get((Guid) id.Value);
                ViewBag.Action = "Edit";
            }

            ViewBag.HubsList = _vehicleViewModelBuilder.Hubs();
            return View(viewmodel);
        }
예제 #2
0
        public ActionResult CreateVehicle(VehicleViewModel vm)
        {
            try
            {
                 _vehicleViewModelBuilder.Save(vm);

                TempData["msg"] = "vehicle Successfully Saved";

                return RedirectToAction("ListVehicles");
            }
            catch (DomainValidationException ve)
            {
                ValidationSummary.DomainValidationErrors(ve, ModelState);
                Log.Debug("Failed to create Container type " + ve.Message);
                ViewBag.HubsList = _vehicleViewModelBuilder.Hubs();
                return View(vm);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                Log.Debug("Failed to create Container type " + ex.Message);
                ViewBag.HubsList = _vehicleViewModelBuilder.Hubs();
                return View(vm);
            }

        }
예제 #3
0
 public void Save(VehicleViewModel vehicleViewModel)
 {
     Vehicle vehicle = Construct(vehicleViewModel);
     _vehicleRepository.Save(vehicle);
 }
예제 #4
0
 private Vehicle Construct(VehicleViewModel vm)
 {
     if (vm.Id == Guid.Empty)
         vm.Id = Guid.NewGuid();
     return new Vehicle(vm.Id)
                {
                    Code = vm.Code,
                    Description = vm.Description,
                    CostCentre = _hubRepository.GetById(vm.HubId) as Hub,
                    EquipmentNumber = vm.RegistrationNumber,
                    Make = vm.Make,
                    Model = vm.Model,
                    Name = vm.Name,
                    EquipmentType = EquipmentType.Vehicle,
                    _Status =  vm.Status,
                   
                };
 }