示例#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 ApiLinkServerResponseModel MapEntityToModel(
            Link item)
        {
            var model = new ApiLinkServerResponseModel();

            model.SetProperties(item.Id,
                                item.AssignedMachineId,
                                item.ChainId,
                                item.DateCompleted,
                                item.DateStarted,
                                item.DynamicParameters,
                                item.ExternalId,
                                item.LinkStatusId,
                                item.Name,
                                item.Order,
                                item.Response,
                                item.StaticParameters,
                                item.TimeoutInSeconds);
            if (item.AssignedMachineIdNavigation != null)
            {
                var assignedMachineIdModel = new ApiMachineServerResponseModel();
                assignedMachineIdModel.SetProperties(
                    item.AssignedMachineIdNavigation.Id,
                    item.AssignedMachineIdNavigation.Description,
                    item.AssignedMachineIdNavigation.JwtKey,
                    item.AssignedMachineIdNavigation.LastIpAddress,
                    item.AssignedMachineIdNavigation.MachineGuid,
                    item.AssignedMachineIdNavigation.Name);

                model.SetAssignedMachineIdNavigation(assignedMachineIdModel);
            }

            if (item.ChainIdNavigation != null)
            {
                var chainIdModel = new ApiChainServerResponseModel();
                chainIdModel.SetProperties(
                    item.ChainIdNavigation.Id,
                    item.ChainIdNavigation.ChainStatusId,
                    item.ChainIdNavigation.ExternalId,
                    item.ChainIdNavigation.Name,
                    item.ChainIdNavigation.TeamId);

                model.SetChainIdNavigation(chainIdModel);
            }

            if (item.LinkStatusIdNavigation != null)
            {
                var linkStatusIdModel = new ApiLinkStatusServerResponseModel();
                linkStatusIdModel.SetProperties(
                    item.LinkStatusIdNavigation.Id,
                    item.LinkStatusIdNavigation.Name);

                model.SetLinkStatusIdNavigation(linkStatusIdModel);
            }

            return(model);
        }
示例#3
0
        public virtual ApiChainClientRequestModel MapServerResponseToClientRequest(
            ApiChainServerResponseModel response)
        {
            var request = new ApiChainClientRequestModel();

            request.SetProperties(
                response.ChainStatusId,
                response.ExternalId,
                response.Name,
                response.TeamId);
            return(request);
        }
示例#4
0
        public virtual ApiChainServerResponseModel MapServerRequestToResponse(
            int id,
            ApiChainServerRequestModel request)
        {
            var response = new ApiChainServerResponseModel();

            response.SetProperties(id,
                                   request.ChainStatusId,
                                   request.ExternalId,
                                   request.Name,
                                   request.TeamId);
            return(response);
        }
示例#5
0
        public void MapEntityToModel()
        {
            var   mapper = new DALChainMapper();
            Chain item   = new Chain();

            item.SetProperties(1, 1, Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), "A", 1);
            ApiChainServerResponseModel response = mapper.MapEntityToModel(item);

            response.ChainStatusId.Should().Be(1);
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
            response.TeamId.Should().Be(1);
        }
示例#6
0
        public virtual async Task <UpdateResponse <ApiChainServerResponseModel> > Update(
            int id,
            ApiChainServerRequestModel model)
        {
            var validationResult = await this.ChainModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Chain record = this.DalChainMapper.MapModelToEntity(id, model);
                await this.ChainRepository.Update(record);

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

                ApiChainServerResponseModel apiModel = this.DalChainMapper.MapEntityToModel(record);
                await this.mediator.Publish(new ChainUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiChainServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiChainServerResponseModel> .UpdateResponse(validationResult));
            }
        }
示例#7
0
        public virtual ApiClaspServerResponseModel MapEntityToModel(
            Clasp item)
        {
            var model = new ApiClaspServerResponseModel();

            model.SetProperties(item.Id,
                                item.NextChainId,
                                item.PreviousChainId);
            if (item.NextChainIdNavigation != null)
            {
                var nextChainIdModel = new ApiChainServerResponseModel();
                nextChainIdModel.SetProperties(
                    item.NextChainIdNavigation.Id,
                    item.NextChainIdNavigation.ChainStatusId,
                    item.NextChainIdNavigation.ExternalId,
                    item.NextChainIdNavigation.Name,
                    item.NextChainIdNavigation.TeamId);

                model.SetNextChainIdNavigation(nextChainIdModel);
            }

            if (item.PreviousChainIdNavigation != null)
            {
                var previousChainIdModel = new ApiChainServerResponseModel();
                previousChainIdModel.SetProperties(
                    item.PreviousChainIdNavigation.Id,
                    item.PreviousChainIdNavigation.ChainStatusId,
                    item.PreviousChainIdNavigation.ExternalId,
                    item.PreviousChainIdNavigation.Name,
                    item.PreviousChainIdNavigation.TeamId);

                model.SetPreviousChainIdNavigation(previousChainIdModel);
            }

            return(model);
        }
示例#8
0
 public void SetPreviousChainIdNavigation(ApiChainServerResponseModel value)
 {
     this.PreviousChainIdNavigation = value;
 }
示例#9
0
 public void SetNextChainIdNavigation(ApiChainServerResponseModel value)
 {
     this.NextChainIdNavigation = value;
 }
示例#10
0
 public ChainUpdatedNotification(ApiChainServerResponseModel record)
 {
     this.Record = record;
 }