Some more fixes
This commit is contained in:
parent
50b756a776
commit
4315eb231f
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace MusicStore.Controllers
|
||||||
{
|
{
|
||||||
private const string PromoCode = "FREE";
|
private const string PromoCode = "FREE";
|
||||||
private readonly MusicStoreContext _dbContext;
|
private readonly MusicStoreContext _dbContext;
|
||||||
|
|
||||||
public CheckoutController(MusicStoreContext dbContext)
|
public CheckoutController(MusicStoreContext dbContext)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
|
@ -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());
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue