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
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);
}
@ -159,7 +159,7 @@ namespace MusicStore.Areas.Admin.Controllers
[HttpPost, ActionName("RemoveAlbum")]
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)
{
@ -182,9 +182,9 @@ namespace MusicStore.Areas.Admin.Controllers
// GET: /StoreManager/GetAlbumIdFromName
// Note: Added for automated testing purpose. Application does not use this.
[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)
{

View File

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