From dbeba581ea303d11d541dca0716034b00b1b2f05 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 16 Aug 2015 16:43:32 -0700 Subject: [PATCH] Revert "React to MVC model binding changes and fix build break" This reverts commit 52e2784f826d2c2deaf7f5decb5d76693244daf4. This 'MVC change' listed here was a compatibility bug with earlier versions of MVC and has been reverted. --- .../Areas/Admin/Controllers/StoreManagerController.cs | 2 +- src/MusicStore/Controllers/AccountController.cs | 2 +- src/MusicStore/Models/AccountViewModels.cs | 2 +- src/MusicStore/Models/Album.cs | 4 ++-- src/MusicStore/Models/ShoppingCart.cs | 6 +++--- src/MvcMusicStore/Models/Album.cs | 4 ++-- src/MvcMusicStore/Models/Order.cs | 6 +++--- src/MvcMusicStore/Models/ShoppingCart.cs | 10 +++++----- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs b/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs index 2a222f445a..9ce074271d 100644 --- a/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs +++ b/src/MusicStore/Areas/Admin/Controllers/StoreManagerController.cs @@ -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"); } diff --git a/src/MusicStore/Controllers/AccountController.cs b/src/MusicStore/Controllers/AccountController.cs index 2bbab82d1a..d58b8837cf 100644 --- a/src/MusicStore/Controllers/AccountController.cs +++ b/src/MusicStore/Controllers/AccountController.cs @@ -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); diff --git a/src/MusicStore/Models/AccountViewModels.cs b/src/MusicStore/Models/AccountViewModels.cs index 05c77a5796..38a9735292 100644 --- a/src/MusicStore/Models/AccountViewModels.cs +++ b/src/MusicStore/Models/AccountViewModels.cs @@ -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 diff --git a/src/MusicStore/Models/Album.cs b/src/MusicStore/Models/Album.cs index 5b6d06e272..bd0aafd6d3 100644 --- a/src/MusicStore/Models/Album.cs +++ b/src/MusicStore/Models/Album.cs @@ -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; } /// - /// TODO: Temporary hack to populate the orderdetails until EF does this automatically. + /// TODO: Temporary hack to populate the orderdetails until EF does this automatically. /// public Album() { diff --git a/src/MusicStore/Models/ShoppingCart.cs b/src/MusicStore/Models/ShoppingCart.cs index a2cae2140e..abcec5b572 100644 --- a/src/MusicStore/Models/ShoppingCart.cs +++ b/src/MusicStore/Models/ShoppingCart.cs @@ -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 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. diff --git a/src/MvcMusicStore/Models/Album.cs b/src/MvcMusicStore/Models/Album.cs index 1be1230103..fa399c0584 100644 --- a/src/MvcMusicStore/Models/Album.cs +++ b/src/MvcMusicStore/Models/Album.cs @@ -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; } diff --git a/src/MvcMusicStore/Models/Order.cs b/src/MvcMusicStore/Models/Order.cs index 3afd03b76d..c06c1a964e 100644 --- a/src/MvcMusicStore/Models/Order.cs +++ b/src/MvcMusicStore/Models/Order.cs @@ -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 OrderDetails { get; set; } } diff --git a/src/MvcMusicStore/Models/ShoppingCart.cs b/src/MvcMusicStore/Models/ShoppingCart.cs index 48090ad925..14842c86b8 100644 --- a/src/MvcMusicStore/Models/ShoppingCart.cs +++ b/src/MvcMusicStore/Models/ShoppingCart.cs @@ -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();