public virtual ApiCountryServerRequestModel MapServerResponseToRequest(
            ApiCountryServerResponseModel response)
        {
            var request = new ApiCountryServerRequestModel();

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

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

            return(model);
        }
        public virtual ApiCountryServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCountryServerRequestModel request)
        {
            var response = new ApiCountryServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Example #4
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");
        }
Example #5
0
        public virtual ApiProvinceServerResponseModel MapEntityToModel(
            Province item)
        {
            var model = new ApiProvinceServerResponseModel();

            model.SetProperties(item.Id,
                                item.CountryId,
                                item.Name);
            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));
            }
        }
Example #7
0
 public void SetCountryIdNavigation(ApiCountryServerResponseModel value)
 {
     this.CountryIdNavigation = value;
 }
Example #8
0
 public CountryUpdatedNotification(ApiCountryServerResponseModel record)
 {
     this.Record = record;
 }