Enabling code to use RedirectToAction helpers.

This commit is contained in:
Praburaj 2014-04-15 11:45:17 -07:00
parent 70b45dbe2d
commit 69dae2d216
4 changed files with 15 additions and 32 deletions

View File

@ -107,9 +107,7 @@ namespace MusicStore.Controllers
if (result.Succeeded) if (result.Succeeded)
{ {
await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false); await SignInManager.SignInAsync(user, isPersistent: false, rememberBrowser: false);
//Bug: No helper methods return RedirectToAction("Index", "Home");
//return RedirectToAction("Index", "Home");
return Redirect("/");
} }
else else
{ {
@ -154,9 +152,7 @@ namespace MusicStore.Controllers
var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);
if (result.Succeeded) if (result.Succeeded)
{ {
//Bug: No helper method return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
//return RedirectToAction("Manage", new { Message = ManageMessageId.ChangePasswordSuccess });
return View();
} }
else else
{ {
@ -181,8 +177,7 @@ namespace MusicStore.Controllers
var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword); var result = await UserManager.ChangePasswordAsync(user, model.OldPassword, model.NewPassword);
if (result.Succeeded) if (result.Succeeded)
{ {
//Bug: No helper method return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
//return RedirectToAction("Manage", new { Message = ManageMessageId.SetPasswordSuccess });
} }
else else
{ {
@ -203,9 +198,7 @@ namespace MusicStore.Controllers
{ {
// Bug: This should call SignInManager.SignOut() once its available // Bug: This should call SignInManager.SignOut() once its available
this.Context.Response.SignOut(); this.Context.Response.SignOut();
//Bug: No helper return RedirectToAction("Index", "Home");
//return RedirectToAction("Index", "Home");
return Redirect("/");
} }
#region Helpers #region Helpers
@ -246,13 +239,14 @@ namespace MusicStore.Controllers
//Bug: https://github.com/aspnet/WebFx/issues/244 //Bug: https://github.com/aspnet/WebFx/issues/244
returnUrl = string.IsNullOrWhiteSpace(returnUrl) ? "/Home" : returnUrl; returnUrl = string.IsNullOrWhiteSpace(returnUrl) ? "/Home" : returnUrl;
//if (Url.IsLocalUrl(returnUrl)) //if (Url.IsLocalUrl(returnUrl))
if(true)
{ {
return Redirect(returnUrl); return Redirect(returnUrl);
} }
//else else
//{ {
// return RedirectToAction("Index", "Home"); return RedirectToAction("Index", "Home");
//} }
} }
#endregion #endregion

View File

@ -59,10 +59,8 @@ namespace MusicStore.Controllers
// Save all changes // Save all changes
db.SaveChanges(); db.SaveChanges();
//Bug: Helper not available return RedirectToAction("Complete",
//return RedirectToAction("Complete", new { id = order.OrderId });
// new { id = order.OrderId });
return View();
} }
} }
catch catch

View File

@ -32,7 +32,6 @@ namespace MusicStore.Controllers
public IActionResult AddToCart(int id) public IActionResult AddToCart(int id)
{ {
// Retrieve the album from the database // Retrieve the album from the database
var addedAlbum = db.Albums var addedAlbum = db.Albums
.Single(album => album.AlbumId == id); .Single(album => album.AlbumId == id);
@ -45,9 +44,7 @@ namespace MusicStore.Controllers
db.SaveChanges(); db.SaveChanges();
// Go back to the main store page for more shopping // Go back to the main store page for more shopping
//Bug: Helper method not available return RedirectToAction("Index");
//return RedirectToAction("Index");
return View();
} }
// //

View File

@ -69,9 +69,7 @@ namespace MusicStore.Controllers
{ {
db.Albums.Add(album); db.Albums.Add(album);
db.SaveChanges(); db.SaveChanges();
//Bug: RedirectToAction() not available return RedirectToAction("Index");
//return RedirectToAction("Index");
return Redirect("/");
} }
ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
@ -106,9 +104,7 @@ namespace MusicStore.Controllers
{ {
db.ChangeTracker.Entry(album).State = EntityState.Modified; db.ChangeTracker.Entry(album).State = EntityState.Modified;
db.SaveChanges(); db.SaveChanges();
//Bug: Missing RedirectToAction helper return RedirectToAction("Index");
//return RedirectToAction("Index");
return Redirect("/");
} }
ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId); ViewBag.GenreId = new SelectList(db.Genres, "GenreId", "Name", album.GenreId);
ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId); ViewBag.ArtistId = new SelectList(db.Artists, "ArtistId", "Name", album.ArtistId);
@ -139,9 +135,7 @@ namespace MusicStore.Controllers
// TODO [EF] Replace with EntitySet.Remove when querying attaches instances // TODO [EF] Replace with EntitySet.Remove when querying attaches instances
db.ChangeTracker.Entry(album).State = EntityState.Deleted; db.ChangeTracker.Entry(album).State = EntityState.Deleted;
db.SaveChanges(); db.SaveChanges();
//Bug: Missing helper return RedirectToAction("Index");
//return RedirectToAction("Index");
return Redirect("/");
} }
//Bug: Can't dispose db. //Bug: Can't dispose db.