public override bool Add(VehicleType vehicleType)
 {
     if (string.IsNullOrEmpty(vehicleType.TypeName))
     {
         throw new Exception("Vehicle Type Name is not provided!");
     }
     return(_vehiclesTypeRepository.Add(vehicleType));
 }
Example #2
0
        public async Task <object> Handle(CreateVehicleTypeCommand command, CancellationToken cancellationToken)
        {
            //if (!command.IsValid())
            //{
            //    NotifyValidationErrors(command);
            //    return Task.FromResult(false as object);
            //}
            VehicleType vehicle = new VehicleType(new Code(command.Code), new Name(command.Name));
            var         result  = await _vehicleTypeRepository.Add(vehicle);

            return(await Task.FromResult(result as object));
        }
 public ActionResult Create(VehicleTypeViewModel model)
 {
     if (ModelState.IsValid)
     {
         VehicleType vehicleType = new VehicleType()
         {
             FareRate = model.FareRate, Name = model.Name
         };
         _vehicleTypeRepository.Add(vehicleType);
         return(RedirectToAction("Index"));
     }
     return(View(model));
 }
Example #4
0
        public async Task CreateVehicle(CreateVehicleModel vehicle)
        {
            var vehicleType = await _typeRepo
                              .GetVehicleTypesByName(vehicle.VehicleType)
                              .SingleOrDefaultAsync();

            if (vehicleType == null)
            {
                vehicleType = new ExampleVehicleType {
                    Name = vehicle.VehicleType
                };
                await _typeRepo.Add(vehicleType);
            }

            var entity = Mapper.Map <ExampleVehicle>(vehicle);

            entity.VehicleType = vehicleType;
            await _vehicleRepo.Add(entity);
        }
 public IActionResult Add([FromBody] VehicleType vehicleType, [FromRoute] int page = 1, [FromRoute] int pagesize = 10)
 {
     _VTypeRepo.Add(vehicleType);
     _VTypeRepo.Save();
     return(VTypesList(page, pagesize));
 }