public int Album_Add(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //"item" is viewmodel object => to Entity object before update!
                Album additem = new Album
                {
                    //load fast - no PK because KEY is DB given
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };

                //staging in local mem
                //at this point code will NOT have send to Database.
                //Therefore will not have the new PKey yet
                context.Albums.Add(additem);


                //commit to Database - on this command the item is shipped to entity deffinition validation then to context DB
                context.SaveChanges();
                //entity instance will have new Pkey attached to the object

                return(additem.AlbumId);
            }
        }
        public void Album_Update(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //"item" is viewmodel object => to Entity object before update!
                Album updateitem = new Album
                {
                    AlbumId      = item.AlbumId,
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };

                //staging in local mem
                //at this point code will NOT have send to Database.

                context.Entry(updateitem).State = System.Data.Entity.EntityState.Modified;


                //commit to Database - on this command the item is shipped to entity deffinition validation then to context DB
                context.SaveChanges();
                //entity instance will have new Pkey attached to the object
            }
        }
Example #3
0
        private int LoadImage(long albumID, int index)
        {
            var   storage = StorageFactory.GetStorage();
            Album album   = storage.GetAlbum(albumID);

            if (album.ImagesCount == 0)
            {
                return(0);
            }

            if (index < 0)
            {
                index = album.ImagesCount - 1;
            }
            if (album.ImagesCount <= index)
            {
                index = 0;
            }

            if (album.ImagesCount > index)
            {
                image = storage.GetAlbumItem(album, index);
            }
            return(index);
        }
Example #4
0
 public void Update(AlbumItem album)
 {
     using (connection.Lock())
     {
         connection.Update(album);
     }
 }
Example #5
0
        public static string GetUserAlbumThumb(AlbumItem image, int maxSize, int pad, string link, ASC.Data.Storage.IDataStore store)
        {
            var sb    = new StringBuilder();
            var limit = GetImageSizeLimit(image, maxSize);

            sb.Append("<a style=\"padding:0px;\" href=\"" + link + "\">");

            if (image != null)
            {
                sb.Append("<img " + limit + " class=\"borderBase\" title=\"" + HttpUtility.HtmlEncode(image.Name) + "\" src=\"" + GetImageUrl(image.ExpandedStoreThumb, store) + "\" />");
            }
            else
            {
                sb.Append("&nbsp;");
            }
            sb.Append("</a>");

            if (image == null)
            {
                return(sb.ToString());
            }
            var date = image.Album.LastUpdate;

            var event_url = PhotoConst.PAGE_DEFAULT + "?" + PhotoConst.PARAM_EVENT + "=" + image.Album.Event.Id;

            return("<span ><table cellpadding='0' cellspacing='0' border='0' class=\"borderBase\"><tr><td><div  style=\"padding:" + pad + "px;background-color:#fff;\">" + sb.ToString() + "</div></td></tr><tr><td class=\"borderBase\" style='border-width:1px 0px 0px 0px;padding-top:1px;background-color:#fff;'></td></tr><tr><td class=\"borderBase\" style='border-width:1px 0px 0px 0px;padding-top:1px;background-color:#fff;'></td></tr></table>" +
                   "<div style='text-align:left;width: 150px;word-wrap: break-word;'><div style=\"padding:10px 5px 5px 5px; width:" + maxSize + "px;\">" +
                   "<a href=\"" + event_url + "\" class=\"linkHeader\">" + HttpUtility.HtmlEncode(image.Album.Event.Name) + "</a></div><div style=\"padding:0px 5px;\"><a href=\"" + PhotoConst.PAGE_PHOTO + "?" + PhotoConst.PARAM_ALBUM + "=" + image.Album.Id + "\">" + Grammatical.PhotosCount(image.Album.ImagesCount) + "</a></div>" +
                   "<div class=\"textMediumDescribe\" style=\"padding:8px 5px 5px 5px;\">" + PhotoManagerResource.LastUpdateTitle + ": " + date.ToShortDateString() + "</div></div></span>");
        }
Example #6
0
        public void Album_Update(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //Due to the fact that we have seperated the handling of our entities, from the data transfer between WebApp and Class library
                //  using the ViewModel classes, we MUST create an instance of the entity and move the data from the ViewModel class
                //  to the entity instance.
                Album updateItem = new Album
                {
                    //for an update, you need to supply your pkey value
                    AlbumId      = item.AlbumId,
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };

                //Staging
                //Setup in Local Memory

                context.Entry(updateItem).State = System.Data.Entity.EntityState.Modified;

                //Commit to database
                //On this command, you
                //  a) Execute entity validation annotation
                //  b) Send your local memory staging to the database for execution

                context.SaveChanges();
            }
        }
Example #7
0
        public int Album_Add(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //Due to the fact that we have seperated the handling of our entities, from the data transfer between WebApp and Class library
                //  using the ViewModel classes, we MUST create an instance of the entity and move the data from the ViewModel class
                //  to the entity instance.
                Album addItem = new Album
                {
                    //Why no pkey set?
                    //pkey is an identity pkey, no value is needed.
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };

                //Staging
                //Setup in Local Memory
                //At this point you will NOT have sent anything to the database.
                //     ****** therefore, you will NOT have your new pkey as yet. ******
                context.Albums.Add(addItem);

                //Commit to database
                //On this command, you
                //  a) Execute entity validation annotation
                //  b) Send your local memory staging to the database for execution
                //After a successful execution, your entity instance will have the new pkey (Identity) value.
                context.SaveChanges();

                //at this point, your entity instance has the new pkey value
                return(addItem.AlbumId);
            }
        }
        public void Album_Update(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //due to the fact that we have separated the handling of our entities
                // from the data transfer between web app and class library
                //using the viewmodel classes, we MUST create an instance
                //of the entity and move the data from the view model class to the entity instance.
                Album updateitem = new Album
                {
                    //for an update, you need to supply a pkey value
                    AlbumId      = item.AlbumId,
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };

                //staging
                //setup in local memory

                context.Entry(updateitem).State = System.Data.Entity.EntityState.Modified;

                //commit to database
                //on this command you
                //A) execute entity validationm annotation
                // B) send your local memory staging to the database for execution
                // after a successful execution your entity instance will have the
                //      new pkey (identity) value
                context.SaveChanges();

                //at this point, your identity instance has the new pkey value
            }
        }
Example #9
0
        public static string GetImagePreviewSizeLimit(AlbumItem image, int maxXSize, int maxYSize)
        {
            if (image == null)
            {
                return("");
            }

            if (image.PreviewSize.Width > maxXSize && image.PreviewSize.Height > maxYSize)
            {
                if ((double)image.PreviewSize.Width / (double)maxXSize > (double)image.PreviewSize.Height / (double)maxYSize)
                {
                    return(" width=\"" + maxXSize + "\"");
                }
                else
                {
                    return(" height=\"" + maxYSize + "\"");
                }
            }
            else if (image.PreviewSize.Width > maxXSize)
            {
                return(" width=\"" + maxXSize + "\"");
            }
            else if (image.PreviewSize.Height > maxYSize)
            {
                return(" height=\"" + maxYSize + "\"");
            }
            else
            {
                return(string.Empty);
            }
        }
        public override async void Execute(object parameter)
        {
            AlbumItem album = null;

            if (parameter is AlbumItem)
            {
                album = parameter as AlbumItem;
            }
            else if (parameter is ItemClickEventArgs)
            {
                var args = parameter as ItemClickEventArgs;
                album = args.ClickedItem as AlbumItem;
            }
            // searching artist from his id
            else if (parameter is int)
            {
                var id = (int)parameter;
                album = await Locator.MediaLibrary.LoadAlbum(id);
            }
            try
            {
                if (album != null)
                {
                    Locator.MusicLibraryVM.CurrentArtist = await Locator.MediaLibrary.LoadArtist(album.ArtistId);

                    Locator.MusicLibraryVM.CurrentAlbum = album;
                }
            }
            catch { }
            if (album != null)
            {
                Locator.NavigationService.Go(VLCPage.AlbumPage);
            }
        }
Example #11
0
        private void UpdateAlbumImageArt(Task<IImageFormat<Image>> task, AlbumItem albumItem)
        {
            switch (task.Status)
            {
                case TaskStatus.RanToCompletion:
                    Dispatcher.Invoke(() =>
                    {
                        if (task.Result == null)
                            return;

                        Image coverArtImage = task.Result.GetImage();

                        if (coverArtImage == null) return;

                        string localFileName = GetCoverArtFilename(albumItem.Child);

                        if (!File.Exists(localFileName))
                            coverArtImage.Save(localFileName);

                        BitmapFrame bitmapFrame = coverArtImage.ToBitmapSource().Resize(BitmapScalingMode.HighQuality, true, (int)(_albumArtSize * ScalingFactor), (int)(_albumArtSize * ScalingFactor));
                        coverArtImage.Dispose();
                        GC.Collect();
                        albumItem.Image = bitmapFrame;
                    });
                    break;
            }
        }
    async Task <Uri> getThumbnail(string path)
    {
        Uri ret    = null;
        var decomp = path.Substring(1).Split('/');

        if (decomp[1] == "track")
        {
            TrackItem track = await Locator.MediaLibrary.LoadTrackById(int.Parse(decomp[4]));

            AlbumItem album = await Locator.MediaLibrary.LoadAlbum(track.AlbumId);

            ret = new Uri(album.AlbumCoverFullUri);
        }
        else if (decomp[1] == "video")
        {
            VideoItem video = await Locator.MediaLibrary.LoadVideoById(int.Parse(decomp[3]));

            ret = new Uri(video.PictureUri);
        }
        else
        {
            throw new ArgumentException("Wrong URL path");
        }

        return(ret);
    }
Example #13
0
        private void FindIndex(AlbumItem item)
        {
            bool find = false;
            int  i    = 0;

            foreach (var a in Albums)
            {
                foreach (var b in a)
                {
                    if (b.Album == item.Album)
                    {
                        find  = true;
                        index = i;
                        break;
                    }
                    i++;
                }
                if (find)
                {
                    break;
                }
            }
            if (!find)
            {
                index = 0;
            }
        }
Example #14
0
        public override async void Execute(object parameter)
        {
            Locator.MusicLibraryVM.IsAlbumPageShown = true;
            AlbumItem album = null;

            if (parameter is AlbumItem)
            {
                album = parameter as AlbumItem;
            }
            else if (parameter is ItemClickEventArgs)
            {
                var args = parameter as ItemClickEventArgs;
                album = args.ClickedItem as AlbumItem;
            }
            // searching artist from his id
            else if (parameter is int)
            {
                var id = (int)parameter;
                album = Locator.MusicLibraryVM.Albums.FirstOrDefault(x => x.Id == id);
            }
            try
            {
                Locator.MusicLibraryVM.CurrentArtist = Locator.MusicLibraryVM.Artists.FirstOrDefault(x => x.Id == album.ArtistId);
                Locator.MusicLibraryVM.CurrentAlbum  = album;
            }
            catch { }
            Locator.NavigationService.Go(VLCPage.AlbumPage);
        }
Example #15
0
        public void SaveAlbumItem(AlbumItem i)
        {
            if (i == null)
            {
                throw new ArgumentNullException("image");
            }

            if (i.Id != 0)
            {
                DbManager
                .ExecuteList(Query("photo_image").Select("ViewsCount", "CommentsCount").Where("Id", i.Id))
                .ForEach(r => { i.ViewsCount = (int)Convert.ToInt64(r[0]); i.CommentsCount = (int)Convert.ToInt64(r[1]); });
            }

            using (var tx = DbManager.BeginTransaction())
            {
                i.Id = DbManager.ExecuteScalar <long>(
                    Insert("photo_image")
                    .InColumns(Mappers.ImageColumns)
                    .Values(i.Id, i.Album.Id, i.Name, i.Description, i.Location, DateTime.UtcNow, i.UserID, i.ThumbnailSize.Width, i.ThumbnailSize.Height, /*i.OriginalSize.Width, i.OriginalSize.Height,*/ i.PreviewSize.Width, i.PreviewSize.Height, i.ViewsCount, i.CommentsCount)
                    .Identity(1, 0L, true)
                    );
                UpdateAlbumImagesCount(i.Album.Id);

                tx.Commit();
            }
        }
Example #16
0
        public int Album_Add(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //due to the fact we have seperaated handling of our entities
                //from the data traansfer beteen webapp and class library
                //using viewmodel classes, we must create an instaance of the entity
                //and move the data from the viewmodel class to the entity instance

                Album addItem = new Album
                {
                    //no pkey is set because it is an identity pkey so no value is needed
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseLabel = item.ReleaseLabel,
                    ReleaseYear  = item.ReleaseYear
                };
                //Staging
                //Setup in local memory
                //At this point you will not have sent anything to the database
                //therefore you will NOT have your new pkey as yet

                context.Albums.Add(addItem);
                //commit to database
                //on this command you
                //  a)executee entity validtion annotation
                //  b)send local memory staging to the database for execution
                //after successful execution your entity instance will have the new pkey(identity) value
                context.SaveChanges();

                //at this point entity instance is has the neww primay key value
                return(addItem.AlbumId);
            }
        }
        public int Album_Add(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //due to the fact that we have separated the handling of our entities from the data transfer between web app and class library using the ViewModel classes, we must create an instance of the entity and move the data from the ViewModel class to the entity instance
                Album addItem = new Album
                {
                    //why no PK set? PK is an identity, no value needed
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };
                //staging
                //setup of local memory
                //at this point you will not have sent anything to the db, therefore you will not have your new PK as yet
                context.Albums.Add(addItem);

                //commit to db
                //on this command you a) execute entity validation annotation b) send your local memory staging to the database for execution
                //after a successful execution your entity instance will have the new PK (Identity) value
                context.SaveChanges();

                //at this point, your entity instance has the new PK value
                return(addItem.AlbumId);
            }
        }
Example #18
0
        public AlbumItem Albums_FindById(int albumid)
        {
            using (var context = new ChinookSystemContext())
            {
                // (...).FirstOrDefault will return either
                //    a) the first record matching the where condition
                //    b) a null value
                // in 1517 when enrity were pubic, we could use
                // the entityframework method extension .Find(xxx)
                // to retreive the database record on the primary key
                // return context.DbSetName.Find(xxx)

                AlbumItem results = (from x in context.Albums
                                     where x.AlbumId == albumid
                                     select new AlbumItem
                {
                    AlbumId = x.AlbumId,
                    Title = x.Title,
                    ReleaseYear = x.ReleaseYear,
                    ArtistId = x.ArtistId,
                    ReleaseLabel = x.ReleaseLabel
                }).FirstOrDefault();
                return(results);
            }
        }
 public IActionResult OperateImage(IFormFile image, int albumId)
 {
     if (ModelState.IsValid)
     {
         try
         {
             if (image != null)
             {
                 var    model           = new AlbumItem();
                 string imageBase64Data = ImageOperations.GetBase64FromFile(image);
                 model.Image   = imageBase64Data;
                 model.AlbumId = albumId;
                 db.Add(model);
                 db.SaveChanges();
                 return(StatusCode(200, "Eklendi"));
             }
             else
             {
                 ModelState.AddModelError("error", "Lütfen Resim Ekleyin!");
             }
         }
         catch (Exception e)
         {
             ModelState.AddModelError("error", "Error! An error occurred while Image creating");
         }
     }
     return(BadRequest(new
     {
         Message = "Some error(s) occurred!",
         StatusCode = 400,
         ModelState = ModelState.ToList()
     }));
 }
        public async Task AddPicture(AlbumItem item, MediaFile image)
        {
            if (image == null)
            {
                return;
            }

            AlbumItem newItem = new AlbumItem
            {
                IsAddButton = false,
                IsReceipt   = item.IsReceipt,
                Album       = CurrentTransaction.ID,
                ImageName   = Guid.NewGuid().ToString(),
                Image       = new byte[image.GetStream().Length]
            };

            image.GetStream().Read(newItem.Image, 0, newItem.Image.Length);

            await _azure.UploadImage(newItem);

            await Refresh();

            HockeyApp.MetricsManager.TrackEvent("Goods Added");
            //}
        }
Example #21
0
        public async Task <IActionResult> PutAlbumItem([FromRoute] int id, [FromBody] AlbumItem albumItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != albumItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(albumItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AlbumItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> AddToCart(AlbumItem productDetails)
        {
            try
            {
                if (productDetails.AlbumId > 0)
                {
                    var user    = _appUserParser.Parse(HttpContext.User);
                    var product = new BasketItem()
                    {
                        Id          = Guid.NewGuid().ToString(),
                        Quantity    = 1,
                        ProductName = productDetails.Title,
                        PictureUrl  = productDetails.AlbumArtUrl,
                        UnitPrice   = productDetails.Price,
                        ProductId   = productDetails.AlbumId.ToString()
                    };
                    await _basketSvc.AddItemToBasket(user, product);
                }
                return(RedirectToAction("Index", "Catalog"));
            }
            catch (BrokenCircuitException)
            {
                // Catch error when Basket.api is in circuit-opened mode
                HandleBrokenCircuitException();
            }

            return(RedirectToAction("Index", "Catalog", new { errorMsg = ViewBag.BasketInoperativeMsg }));
        }
Example #23
0
        public static string GetHTMLSmallThumb(AlbumItem image, int maxSize, string link, bool selected, bool isVisible, ASC.Data.Storage.IDataStore store)
        {
            var sb    = new StringBuilder();
            var limit = GetImageSizeLimit(image, maxSize);

            if (image.Id == 0)
            {
                sb.Append("<td style=\"padding-right:1px;width:" + maxSize + "px;table-layout:fixed;" + (isVisible ? "display:;" : "display:none;") + "\" >&nbsp;</td>");
            }
            else
            {
                sb.Append("<td style=\"padding-right:1px;table-layout:fixed;" + (isVisible ? "display:;" : "display:none;") + "\" >");
                if (selected)
                {
                    sb.Append("<div class='PhotoManager_CurrentPhoto' style=\"background-imagealbumUrll(" + WebImageSupplier.GetAbsoluteWebPath("current.png", PhotoConst.ModuleID) + ");\"></div>");
                }
                sb.Append("<table border='0' cellpadding=\"0\" cellspacing=\"0\"><tr><td class=\"border:0 solid #000000;table-layout:fixed;text-align:center;vertical-align:middle;\">");
                sb.Append("<div style=\"padding:0px;\"><img " + link + " " + limit + " style=\"cursor:pointer; border: solid 0px #FFF;\" title=\"" + HttpUtility.HtmlEncode(image.Name) + "\" src=\"" + GetImageUrl(image.ExpandedStoreThumb, store) + "\" />");

                sb.Append("</div></td></tr></table>");

                sb.Append("</td>");
            }
            return(sb.ToString());
        }
Example #24
0
        public AlbumItemViewModel(AlbumItem albumItem)
        {
            if (albumItem != null)
            {
                Id              = albumItem.Id;
                AlbumId         = albumItem.AlbumId;
                AlbumTitle      = albumItem.Album.Title;
                AlbumController = albumItem.Album.Controller;
                Title           = albumItem.Title;
                Description     = albumItem.Description;
                CreationDate    = albumItem.CreationDate;
                Type            = (AlbumItemType)albumItem.Type;
                switch ((AlbumItemType)albumItem.Type)
                {
                case AlbumItemType.Image:
                    Src = ImageService.GetImageUrl <AlbumItem>(albumItem.Src);
                    break;

                case AlbumItemType.Video:
                    Src = albumItem.Src;
                    break;
                }

                AlbumUserId  = albumItem.Album.UserId;
                AlbumGroupId = albumItem.Album.GroupId;
            }
        }
Example #25
0
 public void Add(AlbumItem album)
 {
     using (connection.Lock())
     {
         connection.Insert(album);
     }
 }
Example #26
0
        private void WriteAlbumItemToXml(AlbumItem albumItem, XmlWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("mhia");

            xmlWriter.WriteNode(nameof(albumItem.NumberOfStrings),
                                albumItem.NumberOfStrings.ToString());
            xmlWriter.WriteNode(nameof(albumItem.Unknown1),
                                albumItem.Unknown1.ToString());
            xmlWriter.WriteNode(nameof(albumItem.AlbumId),
                                albumItem.AlbumId.ToString());
            xmlWriter.WriteNode(nameof(albumItem.Unknown2),
                                albumItem.Unknown2.ToString(CultureInfo.InvariantCulture));
            xmlWriter.WriteNode(nameof(albumItem.Unknown3),
                                albumItem.Unknown3.ToString());

            xmlWriter.WriteNodeWithAttribute("mhod", albumItem.AlbumListArtist, "type",
                                             ((int)DataObjects.AlbumListArtist).ToString());

            xmlWriter.WriteNodeWithAttribute("mhod", albumItem.AlbumListAlbum, "type",
                                             ((int)DataObjects.AlbumListAlbum).ToString());

            xmlWriter.WriteNodeWithAttribute("mhod", albumItem.AlbumListArtistSort, "type",
                                             ((int)DataObjects.AlbumListArtistSort).ToString());

            xmlWriter.WriteEndElement();
        }
Example #27
0
        public int Albums_Add(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //need to move the data from the viewmodel class into
                //  an entity instance BEFORE staging

                //the pkey of the Albums table is an Identity() pKey
                //    therefore you do NOT need to supply the AlbumId value

                Album entityItem = new Album
                {
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseYear  = item.ReleaseYear,
                    ReleaseLabel = item.ReleaseLabel
                };

                //stagging is to local memory
                context.Albums.Add(entityItem);

                //At this point, the new pkey value is NOT available
                //the new pkey value is created by the database

                //commit is the action of sending your request to
                //    the database for action.
                //Also, any validation annotation in your entity definition class
                //    is execute during this command
                context.SaveChanges();
                //since I have an int as the return datatype
                //  I will return the new identity value
                return(entityItem.AlbumId);
            }
        }
Example #28
0
        public void Album_Update(AlbumItem item)
        {
            using (var context = new ChinookSystemContext())
            {
                //due to the fact we have seperaated handling of our entities
                //from the data traansfer beteen webapp and class library
                //using viewmodel classes, we must create an instaance of the entity
                //and move the data from the viewmodel class to the entity instance

                Album updateItem = new Album
                {
                    //Update needs a pkey value
                    AlbumId      = item.AlbumId,
                    Title        = item.Title,
                    ArtistId     = item.ArtistId,
                    ReleaseLabel = item.ReleaseLabel,
                    ReleaseYear  = item.ReleaseYear
                };
                //Staging
                //Setup in local memory

                context.Entry(updateItem).State = System.Data.Entity.EntityState.Modified;
                //commit to database
                //on this command you
                //  a)executee entity validtion annotation
                //  b)send local memory staging to the database for execution
                //after successful execution your entity instance will have the new pkey(identity) value
                context.SaveChanges();
            }
        }
Example #29
0
        public static string GetAlbumThumb(AlbumItem image, int maxSize, int pad, string link, ASC.Data.Storage.IDataStore store)
        {
            var sb    = new StringBuilder();
            var limit = GetImageSizeLimit(image, maxSize);

            sb.Append("<a style=\"text-align:left;padding:0px;\" href=\"" + link + "\">");
            if (image != null)
            {
                sb.Append("<img " + limit + " class=\"borderBase\" title=\"" + HttpUtility.HtmlEncode(image.Name) + "\" src=\"" + GetImageUrl(image.ExpandedStoreThumb, store) + "\" />");
            }
            sb.Append("</a>");

            var date = image.Album.LastUpdate;

            var caption = (string.IsNullOrEmpty(image.Album.Caption) ? DisplayUserSettings.GetFullUserName(new Guid(image.Album.UserID)) : HttpUtility.HtmlEncode(image.Album.Caption));

            var album_url = PhotoConst.PAGE_PHOTO + "?" + PhotoConst.PARAM_ALBUM + "=" + image.Album.Id;

            return
                ("<span>" +
                 "<table cellpadding='0' cellspacing='0' border='0' class=\"borderBase\"><tr><td><div  style=\"padding:" + pad + "px;background-color:#fff;\">" + sb.ToString() + "</div></td></tr><tr><td class=\"borderBase\" style='border-width:1px 0px 0px 0px;padding-top:1px;background-color:#fff;'></td></tr><tr><td class=\"borderBase\" style='border-width:1px 0px 0px 0px;padding-top:1px;background-color:#fff;'></td></tr></table>" +
                 "<div style='text-align:left;width: 150px;word-wrap: break-word;'><div style=\"padding:10px 5px 6px;width:" + maxSize + "px;\">" +
                 "<a href=\"" + album_url + "\" class=\"linkHeader\">" + caption + "</a></div><div style=\"padding:2px 5px 5px;\"><a href=\"" + album_url + "\">" + Grammatical.PhotosCount(image.Album.ImagesCount) + "</a></div>" +
                 "<div class=\"textMediumDescribe\" style=\"padding:5px\">" + PhotoManagerResource.LastUpdateTitle + ": " + date.ToShortDateString() + "</div></div></span>");
        }
Example #30
0
        public static async Task LoadImageToMemory(AlbumItem item)
        {
            /*
             * Normally, We would need more tight calls to try and make sure that the file
             * exists in our database. However, since this is on the UI thread, we can't do that.
             * Since binding images directly through XAML leads to blocked files when we
             * need to delete them, we have to load them up manually. This should be enough
             * of a check, for now, to make sure images load correctly.
             */
            bool fileExists = item.IsPictureLoaded;

            try
            {
                if (fileExists)
                {
                    await DispatchHelper.InvokeAsync(CoreDispatcherPriority.Low, () => item.AlbumImage = new BitmapImage(new Uri(item.AlbumCoverFullUri)));
                }
            }
            catch (Exception)
            {
                LogHelper.Log("Error getting album picture : " + item.Name);
            }
            if (!fileExists)
            {
                try
                {
                    await Locator.MediaLibrary.FetchAlbumCoverOrWaitAsync(item);
                }
                catch { }
            }
        }
Example #31
0
        private async void DeleteSelectedImage()
        {
            if (!await _pageDialogService.DisplayAlertAsync("Warning", "Are you sure you want to delete this image?", "Yes", "No") && !IsUnitTesting)
            {
                return;
            }

            if (SelectedImage == null)
            {
                return;
            }

            IsLoading = true;

            AlbumItem item = SelectedImage.Items.First().Image;

            Images.Remove(SelectedImage);
            await _azure.DeleteImage(item);

            IsLoading = false;

            if (Images.Count < 1)
            {
                await _navigationService.GoBackAsync(new NavigationParameters { ["refreshing"] = true });
            }
        }
Example #32
0
        public AlbumItemModel(AlbumItem item, int itemIndex, string currentAlbumID, string primaryAlbumID, Func<RequestContext, string> getImageUrlBase, IUser currentUser)
        {
            this.item = item;
            this.ItemIndex = itemIndex;
            this.CurrentAlbumID = currentAlbumID;
            this.PrimaryAlbumID = primaryAlbumID;
            this.GetImageUrlBase = getImageUrlBase;

            this.WasProposedToBeDeletedByCurrentUser = item.ProposedToBeDeletedBy == currentUser;
        }
Example #33
0
        public AlbumItem CreateFrom(IFile file, AlbumItemType itemType)
        {
            var item = new AlbumItem(
                file,
                file.Name,
                itemType,
                file.GetLastWriteTime()
            );
            foreach (var store in this.metadataStores) {
                store.LoadMetadataTo(item);
            }

            return item;
        }
Example #34
0
 private void UpdateAlbumImageArt(Task<BitmapFrame> task, AlbumItem albumItem)
 {
     switch (task.Status)
     {
         case TaskStatus.RanToCompletion:
             Dispatcher.Invoke(() =>
             {
                 BitmapFrame coverArtImage = task.Result;
                 if (coverArtImage == null) return;
                 albumItem.Image = coverArtImage;
             });
             break;
         case TaskStatus.Faulted:
             DownloadCoverArt(albumItem);
             break;
     }
 }
Example #35
0
 public void SaveItem(AlbumItem item)
 {
     Argument.VerifyNotNull("item", item);
     this.metadataStores.ForEach(p => p.SaveMetadata(item));
 }
Example #36
0
 private AlbumItemModel ToItemModel(AlbumItem item, int itemIndex, Func<Album, string> getAlbumID, IImageRequestStrategy imageAccess)
 {
     return new AlbumItemModel(
         item, itemIndex, this.ID,
         item.PrimaryAlbum.Get(getAlbumID).Value,
         request => imageAccess.GetActionUrl(request, this.ID, item.Name),
         this.CurrentUser
     );
 }
Example #37
0
 public ItemDetailsViewModel(string albumID, AlbumItem item, IUser currentUser)
 {
     this.AlbumID = albumID;
     this.Item = item;
     this.CurrentUser = currentUser;
 }
Example #38
0
 private void DownloadCoverArt(AlbumItem albumItem)
 {
     SubsonicClient.GetCoverArtAsync(albumItem.Child.CoverArt).ContinueWith(t => UpdateAlbumImageArt(t, albumItem));
 }