Exemplo n.º 1
0
        public async Task <IActionResult> Gallery(string id, CancellationToken cancellationToken)
        {
            Pet pet = await _petsManagementService.GetPet(id, CurrentCookiesToken, cancellationToken);

            List <Photo>        gallery = pet.Gallery;
            List <FineUploader> json    = new List <FineUploader>();

            for (int i = 0; i < gallery.Count; i++)
            {
                var photo = gallery[i];
                json.Add(new FineUploader {
                    UUID = photo.Id, Name = $"Zdj�cie {i+1}.jpg", ThumbnailUrl = $"{_appSettings.Value.ThumbnailsBaseUrl}{photo.FileUrl}"
                });
            }

            CheckUnexpectedErrors();
            return(Json(json));
        }
Exemplo n.º 2
0
        public async void PetsFunctionalityTest()
        {
            _token = await _accountManagementService.SignIn(TestingObjectProvider.Instance.Login);

            Assert.NotNull(_token);

            var pet = TestingObjectProvider.Instance.Pet;

            Assert.NotNull(await _petsManagementService.GetAllPets(_token.Jwt));
            Assert.NotNull(await _petsManagementService.GetPet(pet.Id, _token.Jwt));
            Assert.True(await _petsManagementService.CreatePet(pet, _token.Jwt));
            Assert.True(await _petsManagementService.UpdatePet(pet, _token.Jwt));

            var exception = Record.Exception(() => _petsManagementService.UpdatePet(null, _token.Jwt).Result);

            Assert.IsType(typeof(NullReferenceException), exception?.InnerException);

            Assert.False(await _petsManagementService.CreatePet(null, _token.Jwt));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Index(CancellationToken cancellationToken, CommentState commentState = CommentState.Active)
        {
            var comments = await _commentsManagementService.GetAllComments(CurrentCookiesToken, cancellationToken);

            var viewModels = new List <CommentViewModel>();

            foreach (var comment in comments.Where(c => c.State == commentState))
            {
                var petName = GetFromCache <string>(comment.PetUuid);
                if (petName == null)
                {
                    petName = (await _petsManagementService.GetPet(comment.PetUuid, CurrentCookiesToken, cancellationToken))?.Name;
                    TimeSpan?timeSpan = TimeSpan.FromMinutes(AppSettings.CacheExpirationTimeInMinutes);
                    SetCache(comment.PetUuid, petName, CacheItemPriority.High, timeSpan);
                }

                viewModels.Add(new CommentViewModel()
                {
                    Comment = comment, PetName = petName
                });
            }

            return(View(viewModels.OrderByDescending(x => x.Comment.Created).ToList()));
        }
Exemplo n.º 4
0
 public void TestOfGettingSpecifiedPet()
 {
     Assert.NotNull(_petsManagementService.GetPet(_testingPet.Id, _token.Jwt).Result);
 }