Esempio n. 1
0
        public virtual ApiCountryServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCountryServerRequestModel request)
        {
            var response = new ApiCountryServerResponseModel();

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

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

            return(model);
        }
Esempio n. 3
0
        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");
        }
Esempio n. 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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 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;
 }
Esempio n. 8
0
 public CountryUpdatedNotification(ApiCountryServerResponseModel record)
 {
     this.Record = record;
 }