Revert "React to MVC model binding changes and fix build break"
This reverts commit 52e2784f82.
This 'MVC change' listed here was a compatibility bug with earlier
versions of MVC and has been reverted.
This commit is contained in:
parent
52e2784f82
commit
dbeba581ea
|
|
@ -152,7 +152,7 @@ namespace MusicStore.Areas.Admin.Controllers
|
|||
DbContext.Update(album);
|
||||
await DbContext.SaveChangesAsync(requestAborted);
|
||||
//Invalidate the cache entry as it is modified
|
||||
Cache.Remove(GetCacheKey(album.AlbumId.Value));
|
||||
Cache.Remove(GetCacheKey(album.AlbumId));
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace MusicStore.Controllers
|
|||
|
||||
// This doesn't count login failures towards account lockout
|
||||
// To enable password failures to trigger account lockout, change to lockoutOnFailure: true
|
||||
var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe ?? false , lockoutOnFailure: false);
|
||||
var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, lockoutOnFailure: false);
|
||||
if (result.Succeeded)
|
||||
{
|
||||
return RedirectToLocal(returnUrl);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace MusicStore.Models
|
|||
public string Password { get; set; }
|
||||
|
||||
[Display(Name = "Remember me?")]
|
||||
public bool? RememberMe { get; set; }
|
||||
public bool RememberMe { get; set; }
|
||||
}
|
||||
|
||||
public class RegisterViewModel
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace MusicStore.Models
|
|||
public class Album
|
||||
{
|
||||
[ScaffoldColumn(false)]
|
||||
public int? AlbumId { get; set; }
|
||||
public int AlbumId { get; set; }
|
||||
|
||||
public int GenreId { get; set; }
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ namespace MusicStore.Models
|
|||
public DateTime Created { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TODO: Temporary hack to populate the orderdetails until EF does this automatically.
|
||||
/// TODO: Temporary hack to populate the orderdetails until EF does this automatically.
|
||||
/// </summary>
|
||||
public Album()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace MusicStore.Models
|
|||
// Create a new cart item if no cart item exists
|
||||
cartItem = new CartItem
|
||||
{
|
||||
AlbumId = album.AlbumId.Value,
|
||||
AlbumId = album.AlbumId,
|
||||
CartId = ShoppingCartId,
|
||||
Count = 1,
|
||||
DateCreated = DateTime.Now
|
||||
|
|
@ -100,7 +100,7 @@ namespace MusicStore.Models
|
|||
|
||||
public async Task<decimal> GetTotal()
|
||||
{
|
||||
// Multiply album price by count of that album to get
|
||||
// Multiply album price by count of that album to get
|
||||
// the current price for each of those albums in the cart
|
||||
// sum all album price totals to get the cart total
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ namespace MusicStore.Models
|
|||
|
||||
if (cartId == null)
|
||||
{
|
||||
//A GUID to hold the cartId.
|
||||
//A GUID to hold the cartId.
|
||||
cartId = Guid.NewGuid().ToString();
|
||||
|
||||
// Send cart Id as a cookie to the client.
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace MvcMusicStore.Models
|
||||
namespace MvcMusicStore.Models
|
||||
{
|
||||
public class Album {
|
||||
[ScaffoldColumn(false)]
|
||||
|
||||
public int? AlbumId { get; set; }
|
||||
public int AlbumId { get; set; }
|
||||
|
||||
public int GenreId { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ namespace MvcMusicStore.Models
|
|||
}
|
||||
|
||||
[ScaffoldColumn(false)]
|
||||
public int? OrderId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
|
||||
[ScaffoldColumn(false)]
|
||||
public System.DateTime? OrderDate { get; set; }
|
||||
public System.DateTime OrderDate { get; set; }
|
||||
|
||||
[ScaffoldColumn(false)]
|
||||
public string Username { get; set; }
|
||||
|
|
@ -66,7 +66,7 @@ namespace MvcMusicStore.Models
|
|||
public string Email { get; set; }
|
||||
|
||||
[ScaffoldColumn(false)]
|
||||
public decimal? Total { get; set; }
|
||||
public decimal Total { get; set; }
|
||||
|
||||
public List<OrderDetail> OrderDetails { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ namespace MvcMusicStore.Models
|
|||
|
||||
public async Task AddToCart(Album album)
|
||||
{
|
||||
var cartItem = await GetCartItem(album.AlbumId.Value);
|
||||
var cartItem = await GetCartItem(album.AlbumId);
|
||||
|
||||
if (cartItem == null)
|
||||
{
|
||||
cartItem = new Cart
|
||||
{
|
||||
AlbumId = album.AlbumId.Value,
|
||||
AlbumId = album.AlbumId,
|
||||
CartId = _cartId,
|
||||
Count = 1,
|
||||
DateCreated = DateTime.Now
|
||||
|
|
@ -119,7 +119,7 @@ namespace MvcMusicStore.Models
|
|||
order.OrderDetails.Add(new OrderDetail
|
||||
{
|
||||
AlbumId = item.AlbumId,
|
||||
OrderId = order.OrderId.Value,
|
||||
OrderId = order.OrderId,
|
||||
UnitPrice = item.Album.Price,
|
||||
Quantity = item.Count,
|
||||
});
|
||||
|
|
@ -131,7 +131,7 @@ namespace MvcMusicStore.Models
|
|||
|
||||
await EmptyCart();
|
||||
|
||||
return order.OrderId.Value;
|
||||
return order.OrderId;
|
||||
}
|
||||
|
||||
private async Task EmptyCart()
|
||||
|
|
@ -142,7 +142,7 @@ namespace MvcMusicStore.Models
|
|||
_storeContext.Carts.Remove(cartItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async Task MigrateCart(string userName)
|
||||
{
|
||||
var carts = await _storeContext.Carts.Where(c => c.CartId == _cartId).ToListAsync();
|
||||
|
|
|
|||
Loading…
Reference in New Issue