Example #1
0
        public virtual ApiCountryServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCountryServerRequestModel request)
        {
            var response = new ApiCountryServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Example #2
0
        public virtual ApiCountryServerResponseModel MapEntityToModel(
            Country item)
        {
            var model = new ApiCountryServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name);

            return(model);
        }
        public void MapEntityToModel()
        {
            var     mapper = new DALCountryMapper();
            Country item   = new Country();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
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 ApiDestinationServerResponseModel MapEntityToModel(
            Destination item)
        {
            var model = new ApiDestinationServerResponseModel();

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

                model.SetCountryIdNavigation(countryIdModel);
            }

            return(model);
        }
Example #6
0
        public virtual async Task <UpdateResponse <ApiCountryServerResponseModel> > Update(
            int id,
            ApiCountryServerRequestModel model)
        {
            var validationResult = await this.CountryModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Country record = this.DalCountryMapper.MapModelToEntity(id, model);
                await this.CountryRepository.Update(record);

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

                ApiCountryServerResponseModel apiModel = this.DalCountryMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CountryUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiCountryServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiCountryServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public void SetCountryIdNavigation(ApiCountryServerResponseModel value)
 {
     this.CountryIdNavigation = value;
 }
Example #8
0
 public CountryUpdatedNotification(ApiCountryServerResponseModel record)
 {
     this.Record = record;
 }