示例#1
0
        public virtual ApiEventServerResponseModel MapEntityToModel(
            Event item)
        {
            var model = new ApiEventServerResponseModel();

            model.SetProperties(item.Id,
                                item.Address1,
                                item.Address2,
                                item.CityId,
                                item.Date,
                                item.Description,
                                item.EndDate,
                                item.Facebook,
                                item.Name,
                                item.StartDate,
                                item.Website);
            if (item.CityIdNavigation != null)
            {
                var cityIdModel = new ApiCityServerResponseModel();
                cityIdModel.SetProperties(
                    item.CityIdNavigation.Id,
                    item.CityIdNavigation.Name,
                    item.CityIdNavigation.ProvinceId);

                model.SetCityIdNavigation(cityIdModel);
            }

            return(model);
        }
        public virtual ApiCityClientRequestModel MapServerResponseToClientRequest(
            ApiCityServerResponseModel response)
        {
            var request = new ApiCityClientRequestModel();

            request.SetProperties(
                response.Name,
                response.ProvinceId);
            return(request);
        }
        public virtual ApiCityServerResponseModel MapServerRequestToResponse(
            int id,
            ApiCityServerRequestModel request)
        {
            var response = new ApiCityServerResponseModel();

            response.SetProperties(id,
                                   request.Name,
                                   request.ProvinceId);
            return(response);
        }
示例#4
0
        public void MapEntityToModel()
        {
            var  mapper = new DALCityMapper();
            City item   = new City();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.ProvinceId.Should().Be(1);
        }
示例#5
0
        public virtual ApiCityServerResponseModel MapEntityToModel(
            City item)
        {
            var model = new ApiCityServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name,
                                item.ProvinceId);
            if (item.ProvinceIdNavigation != null)
            {
                var provinceIdModel = new ApiProvinceServerResponseModel();
                provinceIdModel.SetProperties(
                    item.ProvinceIdNavigation.Id,
                    item.ProvinceIdNavigation.CountryId,
                    item.ProvinceIdNavigation.Name);

                model.SetProvinceIdNavigation(provinceIdModel);
            }

            return(model);
        }
示例#6
0
        public virtual async Task <UpdateResponse <ApiCityServerResponseModel> > Update(
            int id,
            ApiCityServerRequestModel model)
        {
            var validationResult = await this.CityModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                City record = this.DalCityMapper.MapModelToEntity(id, model);
                await this.CityRepository.Update(record);

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

                ApiCityServerResponseModel apiModel = this.DalCityMapper.MapEntityToModel(record);
                await this.mediator.Publish(new CityUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiCityServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiCityServerResponseModel> .UpdateResponse(validationResult));
            }
        }
示例#7
0
 public CityUpdatedNotification(ApiCityServerResponseModel record)
 {
     this.Record = record;
 }
示例#8
0
 public void SetCityIdNavigation(ApiCityServerResponseModel value)
 {
     this.CityIdNavigation = value;
 }