public virtual ApiLinkStatusClientRequestModel MapServerResponseToClientRequest(
            ApiLinkStatusServerResponseModel response)
        {
            var request = new ApiLinkStatusClientRequestModel();

            request.SetProperties(
                response.Name);
            return(request);
        }
Beispiel #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 ApiLinkStatusServerResponseModel MapEntityToModel(
            LinkStatus item)
        {
            var model = new ApiLinkStatusServerResponseModel();

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

            return(model);
        }
        public virtual ApiLinkStatusServerResponseModel MapServerRequestToResponse(
            int id,
            ApiLinkStatusServerRequestModel request)
        {
            var response = new ApiLinkStatusServerResponseModel();

            response.SetProperties(id,
                                   request.Name);
            return(response);
        }
        public void MapEntityToModel()
        {
            var        mapper = new DALLinkStatusMapper();
            LinkStatus item   = new LinkStatus();

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

            response.Id.Should().Be(1);
            response.Name.Should().Be("A");
        }
        public virtual async Task <UpdateResponse <ApiLinkStatusServerResponseModel> > Update(
            int id,
            ApiLinkStatusServerRequestModel model)
        {
            var validationResult = await this.LinkStatusModelValidator.ValidateUpdateAsync(id, model);

            if (validationResult.IsValid)
            {
                LinkStatus record = this.DalLinkStatusMapper.MapModelToEntity(id, model);
                await this.LinkStatusRepository.Update(record);

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

                ApiLinkStatusServerResponseModel apiModel = this.DalLinkStatusMapper.MapEntityToModel(record);
                await this.mediator.Publish(new LinkStatusUpdatedNotification(apiModel));

                return(ValidationResponseFactory <ApiLinkStatusServerResponseModel> .UpdateResponse(apiModel));
            }
            else
            {
                return(ValidationResponseFactory <ApiLinkStatusServerResponseModel> .UpdateResponse(validationResult));
            }
        }
 public LinkStatusUpdatedNotification(ApiLinkStatusServerResponseModel record)
 {
     this.Record = record;
 }
Beispiel #8
0
 public void SetLinkStatusIdNavigation(ApiLinkStatusServerResponseModel value)
 {
     this.LinkStatusIdNavigation = value;
 }