Exemplo n.º 1
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 ApiMachineClientRequestModel MapServerResponseToClientRequest(
            ApiMachineServerResponseModel response)
        {
            var request = new ApiMachineClientRequestModel();

            request.SetProperties(
                response.Description,
                response.JwtKey,
                response.LastIpAddress,
                response.MachineGuid,
                response.Name);
            return(request);
        }
        public virtual ApiMachineServerResponseModel MapServerRequestToResponse(
            int id,
            ApiMachineServerRequestModel request)
        {
            var response = new ApiMachineServerResponseModel();

            response.SetProperties(id,
                                   request.Description,
                                   request.JwtKey,
                                   request.LastIpAddress,
                                   request.MachineGuid,
                                   request.Name);
            return(response);
        }
Exemplo n.º 4
0
        public virtual ApiMachineServerResponseModel MapEntityToModel(
            Machine item)
        {
            var model = new ApiMachineServerResponseModel();

            model.SetProperties(item.Id,
                                item.Description,
                                item.JwtKey,
                                item.LastIpAddress,
                                item.MachineGuid,
                                item.Name);

            return(model);
        }
Exemplo n.º 5
0
        public void MapEntityToModel()
        {
            var     mapper = new DALMachineMapper();
            Machine item   = new Machine();

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

            response.Description.Should().Be("A");
            response.Id.Should().Be(1);
            response.JwtKey.Should().Be("A");
            response.LastIpAddress.Should().Be("A");
            response.MachineGuid.Should().Be(Guid.Parse("8420cdcf-d595-ef65-66e7-dff9f98764da"));
            response.Name.Should().Be("A");
        }
Exemplo n.º 6
0
        public virtual async Task <UpdateResponse <ApiMachineServerResponseModel> > Update(
            int id,
            ApiMachineServerRequestModel model)
        {
            var validationResult = await this.MachineModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                Machine record = this.DalMachineMapper.MapModelToEntity(id, model);
                await this.MachineRepository.Update(record);

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

                ApiMachineServerResponseModel apiModel = this.DalMachineMapper.MapEntityToModel(record);
                await this.mediator.Publish(new MachineUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiMachineServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiMachineServerResponseModel> .UpdateResponse(validationResult));
            }
        }
Exemplo n.º 7
0
 public MachineUpdatedNotification(ApiMachineServerResponseModel record)
 {
     this.Record = record;
 }
Exemplo n.º 8
0
 public void SetAssignedMachineIdNavigation(ApiMachineServerResponseModel value)
 {
     this.AssignedMachineIdNavigation = value;
 }