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);
        }
        public virtual ApiColumnSameAsFKTableClientRequestModel MapServerResponseToClientRequest(
            ApiColumnSameAsFKTableServerResponseModel response)
        {
            var request = new ApiColumnSameAsFKTableClientRequestModel();

            request.SetProperties(
                response.Person,
                response.PersonId);
            return(request);
        }
        public virtual ApiColumnSameAsFKTableServerResponseModel MapServerRequestToResponse(
            int id,
            ApiColumnSameAsFKTableServerRequestModel request)
        {
            var response = new ApiColumnSameAsFKTableServerResponseModel();

            response.SetProperties(id,
                                   request.Person,
                                   request.PersonId);
            return(response);
        }
Example #4
0
        public void MapEntityToModel()
        {
            var mapper = new DALColumnSameAsFKTableMapper();
            ColumnSameAsFKTable item = new ColumnSameAsFKTable();

            item.SetProperties(1, 1, 1);
            ApiColumnSameAsFKTableServerResponseModel response = mapper.MapEntityToModel(item);

            response.Id.Should().Be(1);
            response.Person.Should().Be(1);
            response.PersonId.Should().Be(1);
        }
        public virtual async Task <UpdateResponse <ApiColumnSameAsFKTableServerResponseModel> > Update(
            int id,
            ApiColumnSameAsFKTableServerRequestModel model)
        {
            var validationResult = await this.ColumnSameAsFKTableModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                ColumnSameAsFKTable record = this.DalColumnSameAsFKTableMapper.MapModelToEntity(id, model);
                await this.ColumnSameAsFKTableRepository.Update(record);

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

                ApiColumnSameAsFKTableServerResponseModel apiModel = this.DalColumnSameAsFKTableMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ColumnSameAsFKTableUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiColumnSameAsFKTableServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiColumnSameAsFKTableServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Example #6
0
 public ColumnSameAsFKTableUpdatedNotification(ApiColumnSameAsFKTableServerResponseModel record)
 {
     this.Record = record;
 }