コード例 #1
0
        public virtual ApiVehicleCapabilitiesServerRequestModel MapServerResponseToRequest(
            ApiVehicleCapabilitiesServerResponseModel response)
        {
            var request = new ApiVehicleCapabilitiesServerRequestModel();

            request.SetProperties(
                response.VehicleCapabilityId,
                response.VehicleId);
            return(request);
        }
コード例 #2
0
        public virtual ApiVehicleCapabilitiesServerResponseModel MapServerRequestToResponse(
            int id,
            ApiVehicleCapabilitiesServerRequestModel request)
        {
            var response = new ApiVehicleCapabilitiesServerResponseModel();

            response.SetProperties(id,
                                   request.VehicleCapabilityId,
                                   request.VehicleId);
            return(response);
        }
コード例 #3
0
        public void MapModelToEntity()
        {
            var mapper = new DALVehicleCapabilitiesMapper();
            ApiVehicleCapabilitiesServerRequestModel model = new ApiVehicleCapabilitiesServerRequestModel();

            model.SetProperties(1, 1);
            VehicleCapabilities response = mapper.MapModelToEntity(1, model);

            response.VehicleCapabilityId.Should().Be(1);
            response.VehicleId.Should().Be(1);
        }
コード例 #4
0
        public virtual VehicleCapabilities MapModelToEntity(
            int id,
            ApiVehicleCapabilitiesServerRequestModel model
            )
        {
            VehicleCapabilities item = new VehicleCapabilities();

            item.SetProperties(
                id,
                model.VehicleCapabilityId,
                model.VehicleId);
            return(item);
        }
コード例 #5
0
        public virtual async Task <CreateResponse <ApiVehicleCapabilitiesServerResponseModel> > Create(
            ApiVehicleCapabilitiesServerRequestModel model)
        {
            CreateResponse <ApiVehicleCapabilitiesServerResponseModel> response = ValidationResponseFactory <ApiVehicleCapabilitiesServerResponseModel> .CreateResponse(await this.VehicleCapabilitiesModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                VehicleCapabilities record = this.DalVehicleCapabilitiesMapper.MapModelToEntity(default(int), model);
                record = await this.VehicleCapabilitiesRepository.Create(record);

                response.SetRecord(this.DalVehicleCapabilitiesMapper.MapEntityToModel(record));
                await this.mediator.Publish(new VehicleCapabilitiesCreatedNotification(response.Record));
            }

            return(response);
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        public JsonPatchDocument <ApiVehicleCapabilitiesServerRequestModel> CreatePatch(ApiVehicleCapabilitiesServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiVehicleCapabilitiesServerRequestModel>();

            patch.Replace(x => x.VehicleCapabilityId, model.VehicleCapabilityId);
            patch.Replace(x => x.VehicleId, model.VehicleId);
            return(patch);
        }