Пример #1
0
        public virtual ApiChainServerResponseModel MapEntityToModel(
            Chain item)
        {
            var model = new ApiChainServerResponseModel();

            model.SetProperties(item.Id,
                                item.ChainStatusId,
                                item.ExternalId,
                                item.Name,
                                item.TeamId);
            if (item.ChainStatusIdNavigation != null)
            {
                var chainStatusIdModel = new ApiChainStatusServerResponseModel();
                chainStatusIdModel.SetProperties(
                    item.ChainStatusIdNavigation.Id,
                    item.ChainStatusIdNavigation.Name);

                model.SetChainStatusIdNavigation(chainStatusIdModel);
            }

            if (item.TeamIdNavigation != null)
            {
                var teamIdModel = new ApiTeamServerResponseModel();
                teamIdModel.SetProperties(
                    item.TeamIdNavigation.Id,
                    item.TeamIdNavigation.Name,
                    item.TeamIdNavigation.OrganizationId);

                model.SetTeamIdNavigation(teamIdModel);
            }

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

            request.SetProperties(
                response.Name);
            return(request);
        }
Пример #3
0
        public virtual ApiChainStatusServerResponseModel MapServerRequestToResponse(
            int id,
            ApiChainStatusServerRequestModel request)
        {
            var response = new ApiChainStatusServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
Пример #4
0
        public virtual ApiChainStatusServerResponseModel MapEntityToModel(
            ChainStatus item)
        {
            var model = new ApiChainStatusServerResponseModel();

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

            return(model);
        }
        public void MapEntityToModel()
        {
            var         mapper = new DALChainStatusMapper();
            ChainStatus item   = new ChainStatus();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
Пример #6
0
        public virtual async Task <UpdateResponse <ApiChainStatusServerResponseModel> > Update(
            int id,
            ApiChainStatusServerRequestModel model)
        {
            var validationResult = await this.ChainStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                ChainStatus record = this.DalChainStatusMapper.MapModelToEntity(id, model);
                await this.ChainStatusRepository.Update(record);

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

                ApiChainStatusServerResponseModel apiModel = this.DalChainStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ChainStatusUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiChainStatusServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiChainStatusServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Пример #7
0
 public ChainStatusUpdatedNotification(ApiChainStatusServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetChainStatusIdNavigation(ApiChainStatusServerResponseModel value)
 {
     this.ChainStatusIdNavigation = value;
 }