Exemplo n.º 1
0
        public async Task <ActionResult> AddAndEdit()
        {
            List <Album> albums = await AlbumService.ListAlbumsAsync();

            DisplayPhoto photo = TempData["photo"] as DisplayPhoto;

            photo = photo ?? new DisplayPhoto();

            IEnumerable <SelectListItem> albumNames = albums.Select(album => new SelectListItem()
            {
                Text  = album.Name,
                Value = album.Id.ToString()
            }).ToList();

            ViewBag.Albums = albumNames;

            IEnumerable <SelectListItem> photoTypes = CollectionExtensions.GetEnumSelectList <ContentType>();

            ViewBag.ContentTypes = photoTypes;

            return(View(photo));
        }