Some more fixes

This commit is contained in:
Praburaj 2014-12-15 13:11:44 -08:00
parent 50b756a776
commit 4315eb231f
2 changed files with 9 additions and 10 deletions

View File

@ -148,9 +148,9 @@ namespace MusicStore.Areas.Admin.Controllers
// //
// GET: /StoreManager/RemoveAlbum/5 // GET: /StoreManager/RemoveAlbum/5
public IActionResult RemoveAlbum(int id) public async Task<IActionResult> RemoveAlbum(int id)
{ {
var album = _dbContext.Albums.Where(a => a.AlbumId == id).FirstOrDefault(); var album = await _dbContext.Albums.Where(a => a.AlbumId == id).FirstOrDefaultAsync();
return View(album); return View(album);
} }
@ -159,7 +159,7 @@ namespace MusicStore.Areas.Admin.Controllers
[HttpPost, ActionName("RemoveAlbum")] [HttpPost, ActionName("RemoveAlbum")]
public async Task<IActionResult> RemoveAlbumConfirmed(int id) public async Task<IActionResult> RemoveAlbumConfirmed(int id)
{ {
var album = _dbContext.Albums.Where(a => a.AlbumId == id).FirstOrDefault(); var album = await _dbContext.Albums.Where(a => a.AlbumId == id).FirstOrDefaultAsync();
if (album != null) if (album != null)
{ {
@ -182,9 +182,9 @@ namespace MusicStore.Areas.Admin.Controllers
// GET: /StoreManager/GetAlbumIdFromName // GET: /StoreManager/GetAlbumIdFromName
// Note: Added for automated testing purpose. Application does not use this. // Note: Added for automated testing purpose. Application does not use this.
[HttpGet] [HttpGet]
public IActionResult GetAlbumIdFromName(string albumName) public async Task<IActionResult> GetAlbumIdFromName(string albumName)
{ {
var album = _dbContext.Albums.Where(a => a.Title == albumName).FirstOrDefault(); var album = await _dbContext.Albums.Where(a => a.Title == albumName).FirstOrDefaultAsync();
if (album == null) if (album == null)
{ {

View File

@ -57,8 +57,7 @@ namespace MusicStore.Controllers
// Save all changes // Save all changes
await _dbContext.SaveChangesAsync(Context.RequestAborted); await _dbContext.SaveChangesAsync(Context.RequestAborted);
return RedirectToAction("Complete", return RedirectToAction("Complete", new { id = order.OrderId });
new { id = order.OrderId });
} }
} }
catch catch
@ -71,10 +70,10 @@ namespace MusicStore.Controllers
// //
// GET: /Checkout/Complete // GET: /Checkout/Complete
public IActionResult Complete(int id) public async Task<IActionResult> Complete(int id)
{ {
// Validate customer owns this order // Validate customer owns this order
bool isValid = _dbContext.Orders.Any( bool isValid = await _dbContext.Orders.AnyAsync(
o => o.OrderId == id && o => o.OrderId == id &&
o.Username == Context.User.Identity.GetUserName()); o.Username == Context.User.Identity.GetUserName());