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); } }
public IActionResult CreateLink(string communityName) { var model = new CreateLinkCommand { CommunityName = communityName }; return(View(model)); }
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); }
/// <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); }
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 })); }
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); }
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; } }
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)); }