public virtual ApiVehicleCapabilitiesServerResponseModel MapEntityToModel(
            VehicleCapabilities item)
        {
            var model = new ApiVehicleCapabilitiesServerResponseModel();

            model.SetProperties(item.Id,
                                item.VehicleCapabilityId,
                                item.VehicleId);
            if (item.VehicleCapabilityIdNavigation != null)
            {
                var vehicleCapabilityIdModel = new ApiVehCapabilityServerResponseModel();
                vehicleCapabilityIdModel.SetProperties(
                    item.VehicleCapabilityIdNavigation.Id,
                    item.VehicleCapabilityIdNavigation.Name);

                model.SetVehicleCapabilityIdNavigation(vehicleCapabilityIdModel);
            }

            if (item.VehicleIdNavigation != null)
            {
                var vehicleIdModel = new ApiVehicleServerResponseModel();
                vehicleIdModel.SetProperties(
                    item.VehicleIdNavigation.Id,
                    item.VehicleIdNavigation.Name);

                model.SetVehicleIdNavigation(vehicleIdModel);
            }

            return(model);
        }
Example #2
0
        public virtual ApiVehicleCapabilitiesClientRequestModel MapServerResponseToClientRequest(
            ApiVehicleCapabilitiesServerResponseModel response)
        {
            var request = new ApiVehicleCapabilitiesClientRequestModel();

            request.SetProperties(
                response.VehicleCapabilityId,
                response.VehicleId);
            return(request);
        }
Example #3
0
        public virtual ApiVehicleCapabilitiesServerResponseModel MapServerRequestToResponse(
            int id,
            ApiVehicleCapabilitiesServerRequestModel request)
        {
            var response = new ApiVehicleCapabilitiesServerResponseModel();

            response.SetProperties(id,
                                   request.VehicleCapabilityId,
                                   request.VehicleId);
            return(response);
        }
Example #4
0
        public void MapEntityToModel()
        {
            var mapper = new DALVehicleCapabilitiesMapper();
            VehicleCapabilities item = new VehicleCapabilities();

            item.SetProperties(1, 1, 1);
            ApiVehicleCapabilitiesServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.VehicleCapabilityId.Should().Be(1);
            response.VehicleId.Should().Be(1);
        }
        public virtual async Task <UpdateResponse <ApiVehicleCapabilitiesServerResponseModel> > Update(
            int id,
            ApiVehicleCapabilitiesServerRequestModel model)
        {
            var validationResult = await this.VehicleCapabilitiesModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                VehicleCapabilities record = this.DalVehicleCapabilitiesMapper.MapModelToEntity(id, model);
                await this.VehicleCapabilitiesRepository.Update(record);

                record = await this.VehicleCapabilitiesRepository.Get(id);

                ApiVehicleCapabilitiesServerResponseModel apiModel = this.DalVehicleCapabilitiesMapper.MapEntityToModel(record);
                await this.mediator.Publish(new VehicleCapabilitiesUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiVehicleCapabilitiesServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiVehicleCapabilitiesServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public VehicleCapabilitiesUpdatedNotification(ApiVehicleCapabilitiesServerResponseModel record)
 {
     this.Record = record;
 }