Fixing compilation errors in the view components.
Marked one of the controller actions with [HttpGet] to prevent it being chosen for non get methods.
This commit is contained in:
parent
306513a844
commit
10a280580c
|
|
@ -1,8 +1,7 @@
|
||||||
using System;
|
using Microsoft.AspNet.Mvc;
|
||||||
|
using MusicStore.Models;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc;
|
|
||||||
using MusicStore.Models;
|
|
||||||
|
|
||||||
namespace MusicStore.Components
|
namespace MusicStore.Components
|
||||||
{
|
{
|
||||||
|
|
@ -18,16 +17,23 @@ namespace MusicStore.Components
|
||||||
|
|
||||||
public async Task<IViewComponentResult> InvokeAsync()
|
public async Task<IViewComponentResult> InvokeAsync()
|
||||||
{
|
{
|
||||||
var cart = ShoppingCart.GetCart(db, this.Context);
|
var cartItems = await GetCartItems();
|
||||||
|
|
||||||
var cartItems = cart.GetCartItems()
|
|
||||||
.Select(a => a.Album.Title)
|
|
||||||
.OrderBy(x => x);
|
|
||||||
|
|
||||||
ViewBag.CartCount = cartItems.Count();
|
ViewBag.CartCount = cartItems.Count();
|
||||||
ViewBag.CartSummary = string.Join("\n", cartItems.Distinct());
|
ViewBag.CartSummary = string.Join("\n", cartItems.Distinct());
|
||||||
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Task<IOrderedEnumerable<string>> GetCartItems()
|
||||||
|
{
|
||||||
|
var cart = ShoppingCart.GetCart(db, this.Context);
|
||||||
|
|
||||||
|
var cartItems = cart.GetCartItems()
|
||||||
|
.Select(a => a.Album.Title)
|
||||||
|
.OrderBy(x => x);
|
||||||
|
|
||||||
|
return Task.FromResult(cartItems);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,6 +3,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNet.Mvc;
|
using Microsoft.AspNet.Mvc;
|
||||||
using MusicStore.Models;
|
using MusicStore.Models;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace MusicStore.Components
|
namespace MusicStore.Components
|
||||||
{
|
{
|
||||||
|
|
@ -17,6 +18,13 @@ namespace MusicStore.Components
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IViewComponentResult> InvokeAsync()
|
public async Task<IViewComponentResult> InvokeAsync()
|
||||||
|
{
|
||||||
|
var genres = await GetGenres();
|
||||||
|
|
||||||
|
return View(genres);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task<List<Genre>> GetGenres()
|
||||||
{
|
{
|
||||||
// TODO [EF] We don't query related data as yet, so the OrderByDescending isn't doing anything
|
// TODO [EF] We don't query related data as yet, so the OrderByDescending isn't doing anything
|
||||||
//var genres = db.Genres
|
//var genres = db.Genres
|
||||||
|
|
@ -28,8 +36,7 @@ namespace MusicStore.Components
|
||||||
//.ToList();
|
//.ToList();
|
||||||
|
|
||||||
var genres = db.Genres.ToList();
|
var genres = db.Genres.ToList();
|
||||||
|
return Task.FromResult(genres);
|
||||||
return View(genres);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -22,6 +22,7 @@ namespace MusicStore.Controllers
|
||||||
//
|
//
|
||||||
// GET: /Checkout/
|
// GET: /Checkout/
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
public IActionResult AddressAndPayment()
|
public IActionResult AddressAndPayment()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue