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

            request.SetProperties(
                response.Name);
            return(request);
        }
Exemplo n.º 2
0
        public virtual ApiSpeciesServerResponseModel MapServerRequestToResponse(
            int id,
            ApiSpeciesServerRequestModel request)
        {
            var response = new ApiSpeciesServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Exemplo n.º 3
0
        public virtual ApiSpeciesServerResponseModel MapEntityToModel(
            Species item)
        {
            var model = new ApiSpeciesServerResponseModel();

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

            return(model);
        }
Exemplo n.º 4
0
        public void MapEntityToModel()
        {
            var     mapper = new DALSpeciesMapper();
            Species item   = new Species();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Exemplo n.º 5
0
        public virtual ApiBreedServerResponseModel MapEntityToModel(
            Breed item)
        {
            var model = new ApiBreedServerResponseModel();

            model.SetProperties(item.Id,
                                item.Name,
                                item.SpeciesId);
            if (item.SpeciesIdNavigation != null)
            {
                var speciesIdModel = new ApiSpeciesServerResponseModel();
                speciesIdModel.SetProperties(
                    item.SpeciesIdNavigation.Id,
                    item.SpeciesIdNavigation.Name);

                model.SetSpeciesIdNavigation(speciesIdModel);
            }

            return(model);
        }
Exemplo n.º 6
0
        public virtual async Task <UpdateResponse <ApiSpeciesServerResponseModel> > Update(
            int id,
            ApiSpeciesServerRequestModel model)
        {
            var validationResult = await this.SpeciesModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Species record = this.DalSpeciesMapper.MapModelToEntity(id, model);
                await this.SpeciesRepository.Update(record);

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

                ApiSpeciesServerResponseModel apiModel = this.DalSpeciesMapper.MapEntityToModel(record);
                await this.mediator.Publish(new SpeciesUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiSpeciesServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiSpeciesServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public void SetSpeciesIdNavigation(ApiSpeciesServerResponseModel value)
 {
     this.SpeciesIdNavigation = value;
 }
Exemplo n.º 8
0
 public SpeciesUpdatedNotification(ApiSpeciesServerResponseModel record)
 {
     this.Record = record;
 }