Exemplo n.º 1
0
        public virtual ApiAirlineClientRequestModel MapServerResponseToClientRequest(
            ApiAirlineServerResponseModel response)
        {
            var request = new ApiAirlineClientRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Exemplo n.º 2
0
        public virtual ApiAirlineServerResponseModel MapEntityToModel(
            Airline item)
        {
            var model = new ApiAirlineServerResponseModel();

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

            return(model);
        }
Exemplo n.º 3
0
        public virtual ApiAirlineServerResponseModel MapServerRequestToResponse(
            int id,
            ApiAirlineServerRequestModel request)
        {
            var response = new ApiAirlineServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Exemplo n.º 4
0
        public void MapEntityToModel()
        {
            var     mapper = new DALAirlineMapper();
            Airline item   = new Airline();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 5
0
        public virtual async Task <UpdateResponse <ApiAirlineServerResponseModel> > Update(
            int id,
            ApiAirlineServerRequestModel model)
        {
            var validationResult = await this.AirlineModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Airline record = this.DalAirlineMapper.MapModelToEntity(id, model);
                await this.AirlineRepository.Update(record);

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

                ApiAirlineServerResponseModel apiModel = this.DalAirlineMapper.MapEntityToModel(record);
                await this.mediator.Publish(new AirlineUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiAirlineServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiAirlineServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemplo n.º 6
0
 public AirlineUpdatedNotification(ApiAirlineServerResponseModel record)
 {
     this.Record = record;
 }