public virtual ApiColumnSameAsFKTableServerResponseModel MapEntityToModel(
            ColumnSameAsFKTable item)
        {
            var model = new ApiColumnSameAsFKTableServerResponseModel();

            model.SetProperties(item.Id,
                                item.Person,
                                item.PersonId);
            if (item.PersonNavigation != null)
            {
                var personModel = new ApiPersonServerResponseModel();
                personModel.SetProperties(
                    item.PersonNavigation.PersonId,
                    item.PersonNavigation.PersonName);

                model.SetPersonNavigation(personModel);
            }

            if (item.PersonIdNavigation != null)
            {
                var personIdModel = new ApiPersonServerResponseModel();
                personIdModel.SetProperties(
                    item.PersonIdNavigation.PersonId,
                    item.PersonIdNavigation.PersonName);

                model.SetPersonIdNavigation(personIdModel);
            }

            return(model);
        }
Пример #2
0
        public virtual ApiPersonClientRequestModel MapServerResponseToClientRequest(
            ApiPersonServerResponseModel response)
        {
            var request = new ApiPersonClientRequestModel();

            request.SetProperties(
                response.PersonName);
            return(request);
        }
Пример #3
0
        public virtual ApiPersonServerResponseModel MapServerRequestToResponse(
            int personId,
            ApiPersonServerRequestModel request)
        {
            var response = new ApiPersonServerResponseModel();

            response.SetProperties(personId,
                                   request.PersonName);
            return(response);
        }
Пример #4
0
        public virtual ApiPersonServerResponseModel MapEntityToModel(
            Person item)
        {
            var model = new ApiPersonServerResponseModel();

            model.SetProperties(item.PersonId,
                                item.PersonName);

            return(model);
        }
Пример #5
0
        public void MapEntityToModel()
        {
            var    mapper = new DALPersonMapper();
            Person item   = new Person();

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

            response.PersonId.Should().Be(1);
            response.PersonName.Should().Be("A");
        }
Пример #6
0
        public virtual async Task <UpdateResponse <ApiPersonServerResponseModel> > Update(
            int personId,
            ApiPersonServerRequestModel model)
        {
            var validationResult = await this.PersonModelValidator.ValidateUpdateAsync(personId, model);

            if (validationResult.IsValid)
            {
                Person record = this.DalPersonMapper.MapModelToEntity(personId, model);
                await this.PersonRepository.Update(record);

                record = await this.PersonRepository.Get(personId);

                ApiPersonServerResponseModel apiModel = this.DalPersonMapper.MapEntityToModel(record);
                await this.mediator.Publish(new PersonUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiPersonServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiPersonServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #7
0
 public PersonUpdatedNotification(ApiPersonServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetPersonIdNavigation(ApiPersonServerResponseModel value)
 {
     this.PersonIdNavigation = value;
 }