Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("AlbumPostId,UserId,DatePosted,Title,ImagePath")] AlbumPost albumPost)
        {
            if (id != albumPost.AlbumPostId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(albumPost);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlbumPostExists(albumPost.AlbumPostId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["UserId"] = new SelectList(_context.ApplicationUser, "Id", "Id", albumPost.UserId);
            return(View(albumPost));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Check if what we have is createable or not.
        /// </summary>
        /// <param name="provided"></param>
        /// <returns></returns>
        public bool createable(AlbumPost provided)
        {
            caught = provided;
            var res = _factories.FirstOrDefault(x => x.createable(provided));

            return(res != null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// For the sorting of specific albums. This is done on a parameter type Album
        /// with the implementation defaulting to the use of a command factory to instantiate
        /// specific objects for usage. The purpose is to simplify the responsibilities of an
        /// individual service that's in operation.
        /// </summary>
        /// <param name="given"></param>
        /// <returns></returns>
        public async Task <IEnumerable <AlbumView> > SortedAlbums(AlbumPost given)
        {
            if (!_commandFact.createable(given))
            {
                return(null);
            }
            var retrieve = _commandFact.create();
            var got      = await retrieve.execute(_context, given);

            // NB -> we cannot take a sample until all the filtering and sorting is done on the data.
            return(got.ToList().Take(given.pageSize));
        }
Exemplo n.º 4
0
        public async Task <ActionResult <IEnumerable <AlbumView> > > PostSortingAlbs(AlbumPost provided)
        {
            var ret = await _context.SortName(provided.pageSize);

            if (ret == null)
            {
                return(NotFound());
            }
            else
            {
                return(new JsonResult(ret));
            }
        }
Exemplo n.º 5
0
 public bool createable(AlbumPost provided)
 {
     return(provided.sortBy.Equals("name"));
 }
Exemplo n.º 6
0
        /// <summary>
        /// Do a simple sort by the name parameter (in an ascending fashion).
        /// </summary>
        /// <param name="chin"></param>
        /// <param name="prov"></param>
        /// <returns></returns>
        public async Task <IEnumerable <AlbumView> > execute(ChinookContext chin, AlbumPost prov)
        {
            var got = await MoldData.Query(chin);

            return(got.ToList().OrderBy(x => x.name));
        }