From f9693488ca168fd1aaca170ed1d1b0af1711e7d5 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Wed, 7 May 2014 22:06:16 -0700 Subject: [PATCH] Verified the bug in the [Compare] dataannotation attribute. https://github.com/aspnet/WebFx/issues/247 Since ModelState.IsValid is now a bool removing the ==true check. --- src/MusicStore/Controllers/AccountController.cs | 8 +++----- src/MusicStore/Controllers/StoreManagerController.cs | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/MusicStore/Controllers/AccountController.cs b/src/MusicStore/Controllers/AccountController.cs index 1fde4e534e..8f11974766 100644 --- a/src/MusicStore/Controllers/AccountController.cs +++ b/src/MusicStore/Controllers/AccountController.cs @@ -39,7 +39,7 @@ namespace MusicStore.Controllers [ValidateAntiForgeryToken] public async Task Login(LoginViewModel model, string returnUrl) { - if (ModelState.IsValid == true) + if (ModelState.IsValid) { var signInStatus = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, shouldLockout: false); switch (signInStatus) @@ -77,8 +77,7 @@ namespace MusicStore.Controllers [ValidateAntiForgeryToken] public async Task Register(RegisterViewModel model) { - //Bug: https://github.com/aspnet/WebFx/issues/247 - //if (ModelState.IsValid == true) + if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.UserName }; var result = await UserManager.CreateAsync(user, model.Password); @@ -118,8 +117,7 @@ namespace MusicStore.Controllers public async Task Manage(ManageUserViewModel model) { ViewBag.ReturnUrl = Url.Action("Manage"); - //Bug: https://github.com/aspnet/WebFx/issues/247 - //if (ModelState.IsValid == true) + if (ModelState.IsValid) { var user = await GetCurrentUserAsync(); var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); diff --git a/src/MusicStore/Controllers/StoreManagerController.cs b/src/MusicStore/Controllers/StoreManagerController.cs index e875f24ea8..3858c73e1f 100644 --- a/src/MusicStore/Controllers/StoreManagerController.cs +++ b/src/MusicStore/Controllers/StoreManagerController.cs @@ -66,7 +66,7 @@ namespace MusicStore.Controllers [HttpPost] public IActionResult Create(Album album) { - if (ModelState.IsValid == true) + if (ModelState.IsValid) { db.Albums.Add(album); db.SaveChanges(); @@ -100,7 +100,7 @@ namespace MusicStore.Controllers [HttpPost] public IActionResult Edit(Album album) { - if (ModelState.IsValid == true) + if (ModelState.IsValid) { db.ChangeTracker.Entry(album).State = EntityState.Modified; db.SaveChanges();