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)); }
/// <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); }
/// <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)); }
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)); } }
public bool createable(AlbumPost provided) { return(provided.sortBy.Equals("name")); }
/// <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)); }