Esempio n. 1
0
        public void CreateCost(ScAddress node)
        {
            //ищем адресс узла стоимость
            var costAddress = this.FindElementAddress(nrel_cost);

            // ищем адрес узла цена
            var priceAddress = this.FindElementAddress(nrel_price);
            //ищем значение узла по предикату
            double price = this.FindValueByPredicate(node, priceAddress);

            //ищем адрес узла количество
            var quantityAddress = this.FindElementAddress(nrel_quantity);
            //ищем значение узла по предикату
            double quantity = this.FindValueByPredicate(node, quantityAddress);

            //если все найдено, делаем стоимость
            if (price != double.NaN && quantity != double.NaN)
            {

                //создаем ссылку, и задаем ей значение в виде произведения
                var cmdCreateLink = new CreateLinkCommand();
                var rspCreateLink = (CreateLinkResponse)client.Send(cmdCreateLink);

                var cmdSetValue = new SetLinkContentCommand(rspCreateLink.CreatedLinkAddress, new LinkContent(price * quantity));
                var rspSetValue = (SetLinkContentResponse)client.Send(cmdSetValue);

                // соединяем все дугами
                var commonArcAdr = this.CreateArcCommand(ElementType.ConstantCommonArc, node, rspCreateLink.CreatedLinkAddress);
                this.CreateArcCommand(ElementType.PositiveConstantPermanentAccessArc, costAddress, commonArcAdr);

            }
        }
Esempio n. 2
0
        public void CreateCost(ScAddress node)
        {
            //ищем адресс узла стоимость
            var costAddress = this.FindElementAddress(nrel_cost);

            // ищем адрес узла цена
            var priceAddress = this.FindElementAddress(nrel_price);
            //ищем значение узла по предикату
            double price = this.FindValueByPredicate(node, priceAddress);

            //ищем адрес узла количество
            var quantityAddress = this.FindElementAddress(nrel_quantity);
            //ищем значение узла по предикату
            double quantity = this.FindValueByPredicate(node, quantityAddress);

            //если все найдено, делаем стоимость
            if (price != double.NaN && quantity != double.NaN)
            {
                //создаем ссылку, и задаем ей значение в виде произведения
                var cmdCreateLink = new CreateLinkCommand();
                var rspCreateLink = (CreateLinkResponse)client.Send(cmdCreateLink);

                var cmdSetValue = new SetLinkContentCommand(rspCreateLink.CreatedLinkAddress, new LinkContent(price * quantity));
                var rspSetValue = (SetLinkContentResponse)client.Send(cmdSetValue);

                // соединяем все дугами
                var commonArcAdr = this.CreateArcCommand(ElementType.ConstantCommonArc, node, rspCreateLink.CreatedLinkAddress);
                this.CreateArcCommand(ElementType.PositiveConstantPermanentAccessArc, costAddress, commonArcAdr);
            }
        }
Esempio n. 3
0
        public IActionResult CreateLink(string communityName)
        {
            var model = new CreateLinkCommand {
                CommunityName = communityName
            };

            return(View(model));
        }
Esempio n. 4
0
        public void Init()
        {
            _linkRepository         = MockRepository.GenerateMock <ILinkRepository>();
            _domainRepository       = MockRepository.GenerateMock <IDomainRepository>();
            _mediaServiceRepository = MockRepository.GenerateMock <IMediaServiceRepository>();

            _storageService = MockRepository.GenerateMock <IStorage>();

            _createLinkCommand = new CreateLinkCommand(_storageService, _domainRepository, _mediaServiceRepository, _linkRepository);
        }
Esempio n. 5
0
        /// <summary>
        /// Создание новой ссылки.
        /// </summary>
        /// <returns>SC-адрес созданной ссылки</returns>
        public ScAddress CreateLink()
        {
            ScAddress linkAddress = ScAddress.Invalid;

            if (knowledgeBase.IsAvaible)
            {
                var coomand  = new CreateLinkCommand();
                var response = (CreateLinkResponse)knowledgeBase.ExecuteCommand(coomand);
                linkAddress = response.CreatedLinkAddress;
            }
            return(linkAddress);
        }
Esempio n. 6
0
        public async Task <IActionResult> Create(CreateLinkCommand request)
        {
            if (!ModelState.IsValid)
            {
                return(View("Create", request));
            }

            request.User = await userManager.GetUserAsync(HttpContext.User);

            var id = await mediator.Send(request);

            return(RedirectToAction(nameof(Details), new { id }));
        }
Esempio n. 7
0
        public async Task <ActionResult> CreateLink(CreateLinkCommand request, string communityName)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            request.CommunityName = communityName;
            request.User          = await userManager.GetUserAsync(HttpContext.User);

            await mediator.Send(request);

            return(RedirectToAction("GetLinks", new { communityName }));
        }
        public void PostCorrectlyMapsRequest()
        {
            CreateLinkCommand command = null;

            Mock.Arrange(() => dataService.Add(Arg.IsAny <CreateLinkCommand>()))
            .DoInstead((CreateLinkCommand arg) => command = arg)
            .Returns(() => Task.FromResult(true));

            target.Post(defaultRequest);

            Assert.Equal(defaultRequest.NodeAId, command.NodeA.Id);
            Assert.Equal(defaultRequest.NodeAType, command.NodeA.NodeType.Id);
            Assert.Equal(defaultRequest.NodeBId, command.NodeB.Id);
            Assert.Equal(defaultRequest.NodeBType, command.NodeB.NodeType.Id);

            Assert.Equal(LinkFlow.AtoB, command.Direction);
            Assert.Equal(defaultRequest.Strength, command.Strength);
            Assert.Equal(defaultRequest.Type, command.Type.Id);
        }
Esempio n. 9
0
        public void TestInitialize()
        {
            // Cleanup first
            this.TestCleanup();

            // Set data
            var userCommand = new CreateUserCommand(this.SampleData.Name, this.SampleData.Email, this.SampleData.IsDisabled, null);

            this.UnitOfWorkFactory.ExecuteSingleCommand(userCommand);

            this.SampleData.Id      = userCommand.Id;
            this.SampleData.Created = userCommand.Created;

            foreach (Link link in this.SampleData.Links)
            {
                var linkCommand = new CreateLinkCommand(userCommand.Id, link.Title, link.Url);
                this.UnitOfWorkFactory.ExecuteSingleCommand(linkCommand);
                link.Id            = linkCommand.Id;
                link.UserProfileId = userCommand.Id;
            }
        }
Esempio n. 10
0
        public async Task <IActionResult> CreateLink(
            [FromBody] CreateLinkRequest request,
            CancellationToken cancellationToken)
        {
            var createLink = new CreateLinkCommand(
                request.Data,
                request.IsEncrypted,
                request.Secrets,
                request.TtlSeconds);

            var link = await Mediator.Send(createLink, cancellationToken);

            var response = new CreateLinkResponse
            {
                ExpiresAt = link.ExpiresAt,
                LinkId    = link.LinkId
            };

            await LinksService.AddLinksAsync(response);

            return(Created("links/{{hash}}", response));
        }