public JsonPatchDocument <ApiVehCapabilityServerRequestModel> CreatePatch(ApiVehCapabilityServerRequestModel model)
        {
            var patch = new JsonPatchDocument <ApiVehCapabilityServerRequestModel>();

            patch.Replace(x => x.Name, model.Name);
            return(patch);
        }
        public virtual ApiVehCapabilityServerRequestModel MapServerResponseToRequest(
            ApiVehCapabilityServerResponseModel response)
        {
            var request = new ApiVehCapabilityServerRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
        public void MapModelToEntity()
        {
            var mapper = new DALVehCapabilityMapper();
            ApiVehCapabilityServerRequestModel model = new ApiVehCapabilityServerRequestModel();

            model.SetProperties("A");
            VehCapability response = mapper.MapModelToEntity(1, model);

            response.Name.Should().Be("A");
        }
        public virtual ApiVehCapabilityServerResponseModel MapServerRequestToResponse(
            int id,
            ApiVehCapabilityServerRequestModel request)
        {
            var response = new ApiVehCapabilityServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Exemplo n.º 5
0
        public virtual VehCapability MapModelToEntity(
            int id,
            ApiVehCapabilityServerRequestModel model
            )
        {
            VehCapability item = new VehCapability();

            item.SetProperties(
                id,
                model.Name);
            return(item);
        }
Exemplo n.º 6
0
        public virtual async Task <CreateResponse <ApiVehCapabilityServerResponseModel> > Create(
            ApiVehCapabilityServerRequestModel model)
        {
            CreateResponse <ApiVehCapabilityServerResponseModel> response = ValidationResponseFactory <ApiVehCapabilityServerResponseModel> .CreateResponse(await this.VehCapabilityModelValidator.ValidateCreateAsync(model));

            if (response.Success)
            {
                VehCapability record = this.DalVehCapabilityMapper.MapModelToEntity(default(int), model);
                record = await this.VehCapabilityRepository.Create(record);

                response.SetRecord(this.DalVehCapabilityMapper.MapEntityToModel(record));
                await this.mediator.Publish(new VehCapabilityCreatedNotification(response.Record));
            }

            return(response);
        }
Exemplo n.º 7
0
        public virtual async Task <UpdateResponse <ApiVehCapabilityServerResponseModel> > Update(
            int id,
            ApiVehCapabilityServerRequestModel model)
        {
            var validationResult = await this.VehCapabilityModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                VehCapability record = this.DalVehCapabilityMapper.MapModelToEntity(id, model);
                await this.VehCapabilityRepository.Update(record);

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

                ApiVehCapabilityServerResponseModel apiModel = this.DalVehCapabilityMapper.MapEntityToModel(record);
                await this.mediator.Publish(new VehCapabilityUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiVehCapabilityServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiVehCapabilityServerResponseModel> .UpdateResponse(validationResult));
            }
        }