public virtual ApiLinkLogServerResponseModel MapEntityToModel(
            LinkLog item)
        {
            var model = new ApiLinkLogServerResponseModel();

            model.SetProperties(item.Id,
                                item.DateEntered,
                                item.LinkId,
                                item.Log);
            if (item.LinkIdNavigation != null)
            {
                var linkIdModel = new ApiLinkServerResponseModel();
                linkIdModel.SetProperties(
                    item.LinkIdNavigation.Id,
                    item.LinkIdNavigation.AssignedMachineId,
                    item.LinkIdNavigation.ChainId,
                    item.LinkIdNavigation.DateCompleted,
                    item.LinkIdNavigation.DateStarted,
                    item.LinkIdNavigation.DynamicParameters,
                    item.LinkIdNavigation.ExternalId,
                    item.LinkIdNavigation.LinkStatusId,
                    item.LinkIdNavigation.Name,
                    item.LinkIdNavigation.Order,
                    item.LinkIdNavigation.Response,
                    item.LinkIdNavigation.StaticParameters,
                    item.LinkIdNavigation.TimeoutInSeconds);

                model.SetLinkIdNavigation(linkIdModel);
            }

            return(model);
        }
Exemple #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);
        }
        public virtual ApiLinkClientRequestModel MapServerResponseToClientRequest(
            ApiLinkServerResponseModel response)
        {
            var request = new ApiLinkClientRequestModel();

            request.SetProperties(
                response.AssignedMachineId,
                response.ChainId,
                response.DateCompleted,
                response.DateStarted,
                response.DynamicParameters,
                response.ExternalId,
                response.LinkStatusId,
                response.Name,
                response.Order,
                response.Response,
                response.StaticParameters,
                response.TimeoutInSeconds);
            return(request);
        }
        public virtual ApiLinkServerResponseModel MapServerRequestToResponse(
            int id,
            ApiLinkServerRequestModel request)
        {
            var response = new ApiLinkServerResponseModel();

            response.SetProperties(id,
                                   request.AssignedMachineId,
                                   request.ChainId,
                                   request.DateCompleted,
                                   request.DateStarted,
                                   request.DynamicParameters,
                                   request.ExternalId,
                                   request.LinkStatusId,
                                   request.Name,
                                   request.Order,
                                   request.Response,
                                   request.StaticParameters,
                                   request.TimeoutInSeconds);
            return(response);
        }
Exemple #5
0
        public void MapEntityToModel()
        {
            var  mapper = new DALLinkMapper();
            Link item   = new Link();

            item.SetProperties(1, 1, 1, DateTime.Parse("1/1/1987 12:00:00 AM"), DateTime.Parse("1/1/1987 12:00:00 AM"), "A", Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"), 1, "A", 1, "A", "A", 1);
            ApiLinkServerResponseModel response = mapper.MapEntityToModel(item);

            response.AssignedMachineId.Should().Be(1);
            response.ChainId.Should().Be(1);
            response.DateCompleted.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DateStarted.Should().Be(DateTime.Parse("1/1/1987 12:00:00 AM"));
            response.DynamicParameters.Should().Be("A");
            response.ExternalId.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Id.Should().Be(1);
            response.LinkStatusId.Should().Be(1);
            response.Name.Should().Be("A");
            response.Order.Should().Be(1);
            response.Response.Should().Be("A");
            response.StaticParameters.Should().Be("A");
            response.TimeoutInSeconds.Should().Be(1);
        }
Exemple #6
0
        public virtual async Task <UpdateResponse <ApiLinkServerResponseModel> > Update(
            int id,
            ApiLinkServerRequestModel model)
        {
            var validationResult = await this.LinkModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Link record = this.DalLinkMapper.MapModelToEntity(id, model);
                await this.LinkRepository.Update(record);

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

                ApiLinkServerResponseModel apiModel = this.DalLinkMapper.MapEntityToModel(record);
                await this.mediator.Publish(new LinkUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiLinkServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiLinkServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemple #7
0
 public LinkUpdatedNotification(ApiLinkServerResponseModel record)
 {
     this.Record = record;
 }
 public void SetLinkIdNavigation(ApiLinkServerResponseModel value)
 {
     this.LinkIdNavigation = value;
 }