Example #1
0
        public virtual ApiCountryRequirementClientRequestModel MapServerResponseToClientRequest(
            ApiCountryRequirementServerResponseModel response)
        {
            var request = new ApiCountryRequirementClientRequestModel();

            request.SetProperties(
                response.CountryId,
                response.Details);
            return(request);
        }
Example #2
0
        public virtual ApiCountryRequirementServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCountryRequirementServerRequestModel request)
        {
            var response = new ApiCountryRequirementServerResponseModel();

            response.SetProperties(id,
                                   request.CountryId,
                                   request.Details);
            return(response);
        }
        public void MapEntityToModel()
        {
            var mapper = new DALCountryRequirementMapper();
            CountryRequirement item = new CountryRequirement();

            item.SetProperties(1, 1, "A");
            ApiCountryRequirementServerResponseModel response = mapper.MapEntityToModel(item);

            response.CountryId.Should().Be(1);
            response.Details.Should().Be("A");
            response.Id.Should().Be(1);
        }
Example #4
0
        public virtual ApiCountryRequirementServerResponseModel MapEntityToModel(
            CountryRequirement item)
        {
            var model = new ApiCountryRequirementServerResponseModel();

            model.SetProperties(item.Id,
                                item.CountryId,
                                item.Details);
            if (item.CountryIdNavigation != null)
            {
                var countryIdModel = new ApiCountryServerResponseModel();
                countryIdModel.SetProperties(
                    item.CountryIdNavigation.Id,
                    item.CountryIdNavigation.Name);

                model.SetCountryIdNavigation(countryIdModel);
            }

            return(model);
        }
        public virtual async Task <UpdateResponse <ApiCountryRequirementServerResponseModel> > Update(
            int id,
            ApiCountryRequirementServerRequestModel model)
        {
            var validationResult = await this.CountryRequirementModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                CountryRequirement record = this.DalCountryRequirementMapper.MapModelToEntity(id, model);
                await this.CountryRequirementRepository.Update(record);

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

                ApiCountryRequirementServerResponseModel apiModel = this.DalCountryRequirementMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CountryRequirementUpdatedNotification(apiModel));

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