コード例 #1
0
        public async Task <IActionResult> AddAlbum(AddAlbumViewModel model)
        {
            ModelState.Remove("Album.VendorUser");
            ModelState.Remove("AlbumImages.AlbumId");

            if (ModelState.IsValid)
            {
                var VendorUser = await GetCurrentUserAsync();

                Album newAlbum = new Album();
                newAlbum.VendorUser = VendorUser;
                newAlbum.Title      = model.Album.Title;
                context.Add(newAlbum);
                await context.SaveChangesAsync();

                AlbumImages alimg = new AlbumImages();
                alimg.ImageUrl = model.Images.ImageUrl;
                alimg.AlbumId  = newAlbum.AlbumId;
                context.Add(alimg);
                await context.SaveChangesAsync();
            }

            try
            {
                return(RedirectToAction("UpdateProfile", "Vendor"));
            }

            catch (DbUpdateException)
            {
                return(RedirectToAction("Profile", "Vendor"));
            }
        }
コード例 #2
0
        public async void CoverDropped(object sender, object args)
        {
            var e       = (DragEventArgs)args;
            var def     = e.GetDeferral();
            var imageId = await e.DataView.GetTextAsync();

            CoverImage = AlbumImages.FirstOrDefault(i => i.Id == imageId) ?? AlbumImages[0];
        }
コード例 #3
0
        public IActionResult AddImage([FromRoute] int id)
        {
            AlbumImages model = new AlbumImages();

            model.AlbumId = id;

            return(View(model));
        }
コード例 #4
0
        public async Task <IEnumerable <string> > FindAlbumImages(string id)
        {
            string           url    = string.Format("/v3/music/albums/{0}?api_key={1}", id, MusicHelper.FanartTvApiKey);
            AlbumImagesQuery images = await _restApiService.Get <AlbumImagesQuery>(url);

            AlbumImages album = images.Albums.First().Value;

            return(album.AlbumCover.Select(img => img.Url));
        }
コード例 #5
0
 public void AddImageToAlbum(Guid imageID, Guid albumID)
 {
     using (var ctx = new Labb1Context())
     {
         var AddImagesToAlbum = new AlbumImages()
         {
             AlbumID = albumID,
             Id      = imageID
         };
         ctx.albumImage.Add(AddImagesToAlbum);
         ctx.SaveChanges();
     }
 }
コード例 #6
0
            public WebPageData[] ExtractData(HtmlDocument doc)
            {
                AlbumImages.Clear();
                Dictionary <string, string> att = new Dictionary <string, string>();

                att.Add("width", "100%");
                att.Add("style", "background-color: white;");

                var container = Helper.AnyChild(doc.DocumentNode, "table", att, true);

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

                //TODO : add support for http://www.idlebrain.com/movie/photogallery/madhusharma1.html

                var imgNodes = Helper.AllChild(container, "img");

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

                int index = 0;
                List <WebPageData> data = new List <WebPageData>();

                foreach (var imgNode in imgNodes)
                {
                    string thSrc = (webDir.EndsWith("/") ? webDir : webDir + "/") + imgNode.GetAttributeValue("src", "");

                    var singleData = WebPageData.GetTextOnly($"{index++}", "");
                    singleData.IsFinal = true;
                    singleData.UID     = UidGenerator();

                    singleData.ImageUrl = thSrc;    //image link

                    var imgDefi = new ImageDefinition()
                    {
                        thumbnil = thSrc,
                        original = (webDir.EndsWith("/") ? webDir : webDir + "/") + imgNode.GetAttributeValue("src", "").Replace("th_", "")
                    };

                    AlbumImages.Add(imgDefi);

                    data.Add(singleData);
                }
                return(data.ToArray());
            }
コード例 #7
0
        public ActionResult AddImageToAlbums()
        {
            using (var ctx = new Labb1Context())
            {
                var ListOfImages = ctx.image.ToList();
                var ListOfAlbum  = ctx.album.ToList();

                var imageToAlbum = new AlbumImages();
                imageToAlbum.Images = ListOfImages;
                imageToAlbum.Albums = ListOfAlbum;
                return(View(imageToAlbum));
            }
            //var imageToAlbum = new AlbumImages();
            //imageToAlbum.Images = HomeController.Images;
            //imageToAlbum.Albums = AlbumController.Albums;
            //return View(imageToAlbum);
        }
コード例 #8
0
        public IWebPageReader OnClickCallback(WebPageData item)
        {
            switch (currentState)
            {
            case CurrentStateInfo.Unknow:
                break;

            case CurrentStateInfo.ListOfPerson:
                AlbumImages.Clear();
                if (architecture.ListOfAlbumReader == null)     //one level skipped
                {
                    currentState = CurrentStateInfo.ListOfAlbum;
                    return(OnClickCallback(item));
                }
                architecture.ListOfAlbumReader.Url = architecture.ListOfAlbumReader.GetUrl((Person)item.Tag);
                LoadConfig(architecture.ListOfAlbumReader);
                informationForLevel = item.Tag;
                return(this);

            case CurrentStateInfo.ListOfAlbum:
                AlbumImages.Clear();
                if (architecture.ListOfAlbumReader == null)
                {
                    try
                    {
                        item.Tag = Changer.ToAlbum((Person)item.Tag);
                    }
                    catch (Exception) { }
                }

                architecture.ListOfImagesReader.Url = architecture.ListOfImagesReader.GetUrl((Album)item.Tag);
                LoadConfig(architecture.ListOfImagesReader);
                informationForLevel = item.Tag;
                return(this);

            case CurrentStateInfo.ListOfImage:
                break;

            case CurrentStateInfo.ShowImage:
                break;

            default:
                break;
            }
            return(null);
        }
コード例 #9
0
        // GET: Base


        public void SaveImagesByType(int Type, int ID, string ImagePath)
        {
            switch (Type)
            {
            case 1:
                var _serviceImage = new ServiceImages();
                _serviceImage.ServiceID   = ID;
                _serviceImage.ImagePath   = ImagePath;
                _serviceImage.UpdatedDate = DateTime.Now;
                _serviceImage.CreatedDate = DateTime.Now;
                _Globalcontext.ServiceImages.Add(_serviceImage);
                break;

            case 2:
                var _ProductImage = new ProductImages();
                _ProductImage.ProductID   = ID;
                _ProductImage.ImagePath   = ImagePath;
                _ProductImage.UpdatedDate = DateTime.Now;
                _ProductImage.CreatedDate = DateTime.Now;
                _Globalcontext.ProductImages.Add(_ProductImage);
                break;

            case 3:
                var _BrandImage = new BrandImages();
                _BrandImage.BrandID     = ID;
                _BrandImage.ImagePath   = ImagePath;
                _BrandImage.UpdatedDate = DateTime.Now;
                _BrandImage.CreatedDate = DateTime.Now;
                _Globalcontext.BrandImages.Add(_BrandImage);
                break;

            case 4:
                var _AlbumImage = new AlbumImages();
                _AlbumImage.AlbumID     = ID;
                _AlbumImage.ImagePath   = ImagePath;
                _AlbumImage.UpdatedDate = DateTime.Now;
                _AlbumImage.CreatedDate = DateTime.Now;
                _Globalcontext.AlbumImages.Add(_AlbumImage);
                break;

            default:
                break;
            }

            _Globalcontext.SaveChanges();
        }
コード例 #10
0
        public void RemoveImages(object sender, object args)
        {
            var count = CurrentSelection.Count;

            for (int i = 0; i < count; i++)
            {
                AlbumImages.Remove(CurrentSelection[0]);
            }
            if (CurrentSelection.Count != 0)
            {
                CurrentSelection.Clear();
            }
            var cover = AlbumImages.FirstOrDefault(i => i.Id == CoverImage.Id);

            if (cover == null)
            {
                CoverImage = AlbumImages[0];
            }
        }
コード例 #11
0
 private async Task Save()
 {
     IsBusy = true;
     if (IsAlbum)
     {
         var      album    = (AlbumItem)Item;
         string[] imageIds = AlbumImages.Select(i => i.Id).ToArray();
         imageIds = !imageIds.SequenceEqual(album.AlbumImages.Select(i => i.Id).ToArray()) ? imageIds : null;
         string title       = Title != album.Title ? Title : null;
         string description = Description != album.Description ? Description : null;
         string privacy     = ToAlbumPrivacy(AlbumPrivacyIndex);
         privacy = privacy != album.Privacy ? privacy : null;
         string cover    = CoverImage.Id != album.Cover ? CoverImage.Id : null;
         var    response = await Portable.Helpers.Initializer.Albums.UpdateAlbum(album.Id, imageIds, title, description, privacy, cover);
     }
     else
     {
         await Portable.Helpers.Initializer.Images.UpdateImage(Item.Id, Title, Description);
     }
     NavigationService.GoBack();
     IsBusy = false;
 }
コード例 #12
0
        public IActionResult AddImage(AlbumImages image, [FromRoute] int id)
        {
            var albId = context.Album
                        .Where(i => i.AlbumId == id).SingleOrDefault();

            if (ModelState.IsValid)
            {
                image.AlbumId = albId.AlbumId;
                context.Add(image);
            }

            try
            {
                context.SaveChanges();
                return(RedirectToAction("AlbumDetail", new RouteValueDictionary(
                                            new { controller = "Albums", action = "AlbumDetail", Id = id })));
            }

            catch (DbUpdateException)
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
コード例 #13
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            if (e.IsApplicationInstancePreserved)
            {
                //do nothing, app is already activated
            }
            else
            {

                var tombstore = new TransientDataStorage();
                
                isLoginFlag = tombstore.Restore<int>("t_isLoginFlag");
                username = tombstore.Restore<string>("t_username");
                password = tombstore.Restore<string>("t_password");
                gtoken = tombstore.Restore<string>("t_gtoken");
                galbumlist = tombstore.Restore<AlbumsList>("t_galbumlist");
                selectedAlbumIndex = tombstore.Restore<int>("t_selectedAlbumIndex");
                selectedImageIndex = tombstore.Restore<int>("t_selectedImageIndex");
                galbumImages = tombstore.Restore<AlbumImages>("t_galbumImages");
            }
         }
コード例 #14
0
        // Code to execute when the application is activated (brought to foreground)
        // This code will not execute when the application is first launched
        private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            // tomb stoning
            if (!e.IsApplicationInstancePreserved)
            {
                
                if (PhoneApplicationService.Current.State.ContainsKey("albumImages"))
                {
                    albumImages = (AlbumImages)PhoneApplicationService.Current.State["albumImages"];
                }
                if (PhoneApplicationService.Current.State.ContainsKey("selectedImageIndex"))
                {
                    selectedImageIndex = (int)PhoneApplicationService.Current.State["selectedImageIndex"];
                }
                if (PhoneApplicationService.Current.State.ContainsKey("selectedAlbumImageIndex"))
                {
                    selectedAlbumImageIndex = (int)PhoneApplicationService.Current.State["selectedAlbumImageIndex"];
                } 
            }

        }
コード例 #15
0
        public WebPageData[] ExtractData(HtmlDocument doc)
        {
            arrangeCurrentState();

            List <WebPageData> data = new List <WebPageData>();

            switch (currentState)
            {
            case CurrentStateInfo.Unknow:
                break;

            case CurrentStateInfo.ListOfPerson:
                AlbumImages.Clear();
                var persons = architecture.ListOfPersonReader.GetListOfPerson(doc);
                foreach (var person in persons)
                {
                    WebPageData singleData = new WebPageData();
                    singleData.IsFinal           = true;
                    singleData.ImageUrl          = person.ImageUrl;
                    singleData.mainText          = person.Name;
                    singleData.subText           = (person.Description == string.Empty ? "" : person.Description);
                    singleData.NoOfItemsIncluded = person.NoOfAlbums;
                    singleData.UID = MyGlobal.UidGenerator();
                    singleData.Tag = person;

                    data.Add(singleData);
                }
                break;

            case CurrentStateInfo.ListOfAlbum:

                if (architecture.ListOfAlbumReader == null)
                {
                    currentState = CurrentStateInfo.ListOfPerson;
                    return(ExtractData(doc));
                }

                AlbumImages.Clear();
                var albums = architecture.ListOfAlbumReader.GetAlbumList((Person)informationForLevel, doc);
                foreach (var album in albums)
                {
                    WebPageData singleData = new WebPageData();
                    singleData.IsFinal  = true;
                    singleData.ImageUrl = album.ImageUrl;
                    singleData.mainText = album.Name;

                    singleData.subText           = (album.Description == string.Empty ? "" : album.Description);
                    singleData.NoOfItemsIncluded = album.NoOfImages;
                    singleData.UID = MyGlobal.UidGenerator();
                    singleData.Tag = album;

                    data.Add(singleData);
                }
                break;

            case CurrentStateInfo.ListOfImage:
                var images = architecture.ListOfImagesReader.GetImageList((Album)informationForLevel, doc);
                foreach (var img in images)
                {
                    WebPageData singleData = new WebPageData();
                    singleData.IsFinal  = true;
                    singleData.ImageUrl = img.Image.thumbnil;
                    singleData.mainText = img.Name;
                    singleData.UID      = MyGlobal.UidGenerator();

                    data.Add(singleData);
                    AlbumImages.Add(img.Image);     //get the data for the next level and cached it
                }
                break;

            case CurrentStateInfo.ShowImage:
                break;

            default:
                break;
            }
            return(data.Count == 0 ? null : data.ToArray());
        }