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)); }
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)); }
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())); }
public void TestOfGettingSpecifiedPet() { Assert.NotNull(_petsManagementService.GetPet(_testingPet.Id, _token.Jwt).Result); }