Example #1
0
        public async Task Set(LinkRecord record, CancellationToken token = default)
        {
            record.VerifyNotNull(nameof(record));

            ILinkRecordActor actor = _actorHost !.GetActor <ILinkRecordActor>((ActorKey)record.Id);
            await actor.Set(record, token);
        }
Example #2
0
        public async Task GivenLinkRecord_WhenFullLifeCycle_ShouldComplete()
        {
            TestWebsiteHost host = await TestApplication.DefaultHost.GetHost();

            const string id          = "lnk0001";
            const string redirectUrl = "http://localhost:5003/Document";

            var record = new LinkRecord
            {
                Id          = id,
                RedirectUrl = redirectUrl
            };

            await host.PathFinderClient.Link.Delete(record.Id);

            LinkRecord?response = await host.PathFinderClient.Link.Get(record.Id);

            response.Should().BeNull();

            await host.PathFinderClient.Link.Set(record);

            LinkRecord?readResponse = await host.PathFinderClient.Link.Get(record.Id);

            readResponse.Should().NotBeNull();
            (record == readResponse).Should().BeTrue();

            await host.PathFinderClient.Link.Delete(record.Id);

            readResponse = await host.PathFinderClient.Link.Get(record.Id);

            readResponse.Should().BeNull();
        }
Example #3
0
        public async Task <IActionResult> Post([FromBody] LinkRecord record)
        {
            record.Prepare();

            await _linkPathService.Set(record);

            return(Ok());
        }
Example #4
0
        public async Task Set(LinkRecord linkRecord)
        {
            linkRecord.VerifyNotNull(nameof(linkRecord));

            HttpResponseMessage response = await _httpClient.PostAsJsonAsync("api/link", linkRecord);

            response.EnsureSuccessStatusCode();
        }
Example #5
0
 public bool Update(LinkRecord linkRecord)
 {
     if (linkRecord != null && GetById(linkRecord.Id) != null)
     {
         context.LinkRecords.Update(linkRecord);
         return((context.SaveChanges() > 0) ? true : false);
     }
     return(false);
 }
Example #6
0
 public bool Insert(LinkRecord linkRecord)
 {
     if (linkRecord != null &&
         GetAll().SingleOrDefault(c => c.Url == linkRecord.Url) == null)
     {
         context.LinkRecords.Add(linkRecord);
         return((context.SaveChanges() > 0) ? true : false);
     }
     return(false);
 }
Example #7
0
        public async Task Set(LinkRecord linkRecord, CancellationToken token = default)
        {
            _logger.LogTrace($"{nameof(Set)}: Id={linkRecord.Id}");

            linkRecord
            .VerifyNotNull(nameof(linkRecord))
            .Prepare();

            await _httpClient.PostAsJsonAsync("api/link", linkRecord, token);
        }
        private void CreateLinkTemplate(int index, string file)
        {
            var record = new LinkRecord
            {
                Id          = $"Link_{index}",
                RedirectUrl = "http://redirect",
            };

            File.WriteAllText(file, _json.SerializeFormat(record));
            _logger.LogInformation($"Create json template {file} for Link");
        }
        public async Task Set(LinkRecord record, CancellationToken token)
        {
            record
            .VerifyNotNull(nameof(record))
            .VerifyAssert(x => x.Id == base.ActorKey.Value, "Id mismatch");

            _logger.LogTrace($"{nameof(Set)}: Writing {record}");
            await _container.Set(record, token);

            _recordCache.Set(record);
        }
Example #10
0
        public void AddLink(int titleId, string linkName, string url)
        {
            var        titleRecord = _titleRepository.Get(o => o.Id == titleId);
            LinkRecord record      = new LinkRecord
            {
                Name = linkName,
                Url  = url
            };

            titleRecord.LinkRecords.Add(record);
            _linkRepository.Create(record);
            _titleRepository.Update(titleRecord);
        }
Example #11
0
        private async Task WriteRecord(string recordType, string json, CancellationToken token)
        {
            switch (recordType)
            {
            case nameof(LinkRecord):
                LinkRecord linkRecord = _json.Deserialize <LinkRecord>(json);
                await _linkContainer.Set(linkRecord, token);

                break;

            case nameof(MetadataRecord):
                MetadataRecord metadataRecord = _json.Deserialize <MetadataRecord>(json);
                await _metadataContainer.Set(metadataRecord, token);

                break;

            default:
                throw new ArgumentException($"Unknown record type for importing, recordType={recordType}");
            }
        }
Example #12
0
        private async Task LoadData()
        {
            ErrorMessage = null;
            if (Id.IsEmpty())
            {
                return;
            }

            try
            {
                FormData        = (await LinkService.Get(Id !)) ?? throw new ArgumentException();
                CurrentFormData = new LinkRecord(FormData);

                FormData.Tags.Add(new KeyValue(string.Empty, string.Empty));
            }
            catch
            {
                ErrorMessage = $"Failed to load Link Id={Id}";
            }

            StateHasChanged();
        }
Example #13
0
        public async Task GivenLinkRecord_WhenRedirect_ReturnsRedirect()
        {
            TestWebsiteHost host = await TestApplication.DefaultHost.GetHost();

            const string id          = "relnk0001";
            const string redirectUrl = "http://localhost:5003/Document";

            var record = new LinkRecord
            {
                Id          = id,
                RedirectUrl = redirectUrl
            };

            await host.PathFinderClient.Link.Set(record);

            HttpResponseMessage response = await host.Client.GetAsync($"link/{record.Id}");

            response.Should().NotBeNull();
            response.StatusCode.Should().Be(HttpStatusCode.Redirect);
            response.Headers?.Location?.Should().NotBeNull();
            response.Headers !.Location !.ToString().Should().Be(record.RedirectUrl);
        }
Example #14
0
 public async Task Set(LinkRecord linkRecord, CancellationToken token = default) => await _pathFinderClient.Link.Set(linkRecord, token);
Example #15
0
 public void EditLink(LinkRecord record)
 {
     _linkRepository.Update(record);
 }
Example #16
0
        } // end of GetAttachments

        /// <summary>
        /// Populate and migrate the reference type record, if not already migrated
        /// also sets the required link information
        /// </summary>
        /// <param name="linkRec">Linked Record information</param>
        /// <returns>true if all referenced records are migrated successfully</returns>
        private bool AddReferenceRecord(LinkRecord linkRec)
        {
# if DEBUG
Example #17
0
 /// <summary>
 /// ctor sets all VM properties except behaviors
 /// </summary>
 public ItemVM(LinkRecord l) : this(l.Link, l.OtherId, l.Description)
 {
 }
Example #18
0
        private void OnRowSelect(LinkRecord linkRecord)
        {
            linkRecord.VerifyNotNull(nameof(linkRecord));

            NavigationManager.NavigateTo(NavigationHelper.Link.EditLinkPage(linkRecord.Id));
        }