Ejemplo n.º 1
0
 public async void GetLibraryListHeader(string id)
 {
     await Task.Run(() =>
     {
         var ga           = new GetAlbum();
         APIhelper.Header = ga.GetAlbumInfo(id);
         RaisePropertyChanged("GetLibraryListHeader");
     });
 }
Ejemplo n.º 2
0
 public object GetJson(GetAlbum request)
 {
     using (var db = dbFactory.Open()) {
         var albums = db.SelectByIds <Album>(new[] { request.Id }).Where(a => a.CategoryId == request.CategoryId);
         if (albums.Any())
         {
             return(new AlbumsResponse {
                 Status = "success",
                 Data = albums
             });
         }
         else
         {
             throw HttpError.NotFound("Album not found.");
         }
     }
 }
Ejemplo n.º 3
0
        public OwnedAlbum OwnedPhotoAlbum([FromBody] GetAlbum model)
        {
            var userId = _http.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier) ?? "00000000-0000-0000-0000-000000000000";

            var authenticated = _http.HttpContext.User.Identity.IsAuthenticated;

            if (model == null)
            {
                return(null);
            }

            if (model.UserId != userId || !authenticated)
            {
                return(null);
            }

            var    totalCount = _db.Photos.Where(x => x.UserId == model.UserId).ToList().Count();
            var    converted  = Convert.ToDouble(totalCount);
            double result     = converted / 24;
            double pages      = Math.Ceiling(result);
            var    photos     = _db.Photos.Where(x => x.UserId == model.UserId).Skip(model.Skip).Take(24);

            List <OwnedPhoto> pics = new List <OwnedPhoto>();

            foreach (var item in photos)
            {
                pics.Add(new OwnedPhoto
                {
                    HasPrice = item.HasPrice,
                    PhotoId  = item.Id,
                    PhotoUrl = item.Url,
                    Price    = item.Price,
                    Title    = item.Title,
                });
            }

            OwnedAlbum album = new OwnedAlbum
            {
                CurrentPhotos = pics,
                TotalPhotos   = totalCount,
                Pages         = Convert.ToInt32(pages),
            };

            return(album);
        }