Methodize status message handling
This commit is contained in:
@@ -37,7 +37,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
|
FormsAuthentication.SetAuthCookie(model.Username, model.RememberMe);
|
||||||
TempData["StatusMessage"] = "Logged in as " + model.Username;
|
SetStatusMessage("Logged in as " + model.Username);
|
||||||
return RedirectToLocal(returnUrl);
|
return RedirectToLocal(returnUrl);
|
||||||
}
|
}
|
||||||
ModelState.AddModelError("", "The user name or password provided is incorrect.");
|
ModelState.AddModelError("", "The user name or password provided is incorrect.");
|
||||||
@@ -70,7 +70,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
[ValidateAntiForgeryToken]
|
[ValidateAntiForgeryToken]
|
||||||
public ActionResult LogOff()
|
public ActionResult LogOff()
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = User.Identity.Name + " logged off";
|
SetStatusMessage(User.Identity.Name + " logged off");
|
||||||
|
|
||||||
FormsAuthentication.SignOut();
|
FormsAuthentication.SignOut();
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
if (changePasswordSucceeded)
|
if (changePasswordSucceeded)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Your password has been changed.";
|
SetStatusMessage("Your password has been changed.");
|
||||||
return RedirectToAction("Manage");
|
return RedirectToAction("Manage");
|
||||||
}
|
}
|
||||||
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
|
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
|
||||||
@@ -169,18 +169,16 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var email = new EmailNotificationService();
|
var email = new EmailNotificationService();
|
||||||
var resetPasswordUrl = ResetPassword(user);
|
var resetPasswordUrl = ResetPassword(user);
|
||||||
email.SendResetPassword(user, resetPasswordUrl);
|
email.SendResetPassword(user, resetPasswordUrl);
|
||||||
TempData["StatusMessage"] = "Please check your email - we have sent a request for you to reset the password.";
|
SetStatusMessage("Please check your email - we have sent a request for you to reset the password.");
|
||||||
}
|
}
|
||||||
else if (user == null)
|
else if (user == null)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Could not find username " + viewModel.Username + ".";
|
SetStatusMessage("Could not find username " + viewModel.Username + ".", StatusType.Error);
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
|
||||||
return RedirectToAction("ResetPassword");
|
return RedirectToAction("ResetPassword");
|
||||||
}
|
}
|
||||||
else if (!user.IsApproved)
|
else if (!user.IsApproved)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Account is disabled for " + viewModel.Username + ".";
|
SetStatusMessage("Account is disabled for " + viewModel.Username + ".", StatusType.Error);
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// even when if not successful, let the user think they're getting a cookie
|
// even when if not successful, let the user think they're getting a cookie
|
||||||
@@ -232,7 +230,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
FormsAuthentication.SetAuthCookie(viewModel.Username, false);
|
FormsAuthentication.SetAuthCookie(viewModel.Username, false);
|
||||||
TempData["StatusMessage"] = "Password set for " + viewModel.Username + ", logged in";
|
SetStatusMessage("Password set for " + viewModel.Username + ", logged in");
|
||||||
return RedirectToAction("Index", "CreateLog");
|
return RedirectToAction("Index", "CreateLog");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
DataService.AddCity(city);
|
DataService.AddCity(city);
|
||||||
|
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage("City " + city.Name + " created", StatusType.Success);
|
||||||
TempData["StatusMessage"] = "City " + city.Name + " created";
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -108,5 +108,26 @@ namespace MileageTraker.Web.Controllers
|
|||||||
select msg;
|
select msg;
|
||||||
return errorList;
|
return errorList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected enum StatusType
|
||||||
|
{
|
||||||
|
Info,
|
||||||
|
Success,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void SetStatusMessage(string msg, StatusType statusType = StatusType.Info)
|
||||||
|
{
|
||||||
|
TempData["StatusMessage"] = msg;
|
||||||
|
switch (statusType)
|
||||||
|
{
|
||||||
|
case StatusType.Success:
|
||||||
|
TempData["StatusMessage-Type"] = "alert-success";
|
||||||
|
break;
|
||||||
|
case StatusType.Error:
|
||||||
|
TempData["StatusMessage-Type"] = "alert-error";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,15 +71,13 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
DataService.UpdateLog(log);
|
DataService.UpdateLog(log);
|
||||||
|
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage(@"You've successfully updated an entry
|
||||||
TempData["StatusMessage"] =
|
|
||||||
@"You've successfully updated an entry
|
|
||||||
traveling to <strong>" + viewModel.CityName + @"</strong>
|
traveling to <strong>" + viewModel.CityName + @"</strong>
|
||||||
for <strong>" + log.Purpose.Purpose + @"</strong>
|
for <strong>" + log.Purpose.Purpose + @"</strong>
|
||||||
on <strong>" + viewModel.Date.ToShortDateString() + @"</strong>
|
on <strong>" + viewModel.Date.ToShortDateString() + @"</strong>
|
||||||
in Vehicle Id <strong>" + viewModel.VehicleId + @"</strong>
|
in Vehicle Id <strong>" + viewModel.VehicleId + @"</strong>
|
||||||
ending in <strong>" + viewModel.EndOdometer + @"</strong>
|
ending in <strong>" + viewModel.EndOdometer + @"</strong>
|
||||||
miles on the odometer.";
|
miles on the odometer.", StatusType.Success);
|
||||||
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
@@ -121,8 +119,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
DataService.AddLog(log);
|
DataService.AddLog(log);
|
||||||
var editLink = Url.Action("EditPast", "CreateLog", new {id = log.LogId});
|
var editLink = Url.Action("EditPast", "CreateLog", new {id = log.LogId});
|
||||||
|
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage(
|
||||||
TempData["StatusMessage"] =
|
|
||||||
@"You've successfully created an entry
|
@"You've successfully created an entry
|
||||||
traveling to <strong>" + model.CityName + @"</strong>
|
traveling to <strong>" + model.CityName + @"</strong>
|
||||||
for <strong>" + log.Purpose.Purpose + @"</strong>
|
for <strong>" + log.Purpose.Purpose + @"</strong>
|
||||||
@@ -130,7 +127,8 @@ namespace MileageTraker.Web.Controllers
|
|||||||
in Vehicle Id <strong>" + model.VehicleId + @"</strong>
|
in Vehicle Id <strong>" + model.VehicleId + @"</strong>
|
||||||
ending in <strong>" + model.EndOdometer + @"</strong>
|
ending in <strong>" + model.EndOdometer + @"</strong>
|
||||||
miles on the odometer. " +
|
miles on the odometer. " +
|
||||||
@"<a href='" + editLink + @"' class='btn btn-mini btn-success'>Edit</a>";
|
@"<a href='" + editLink + @"' class='btn btn-mini btn-success'>Edit</a>",
|
||||||
|
StatusType.Success);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,13 +189,12 @@ namespace MileageTraker.Web.Controllers
|
|||||||
}
|
}
|
||||||
catch (OutOfMemoryException)
|
catch (OutOfMemoryException)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Problem reading excel document - please verify that the document is in Excel 97-2003 Workbook (.xls) format";
|
SetStatusMessage(
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
"Problem reading excel document - please verify that the document is in Excel 97-2003 Workbook (.xls) format", StatusType.Error);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Problem reading excel document: " + ex.Message;
|
SetStatusMessage("Problem reading excel document: " + ex.Message, StatusType.Error);
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return RedirectToAction("ImportUpload");
|
return RedirectToAction("ImportUpload");
|
||||||
|
|||||||
@@ -150,8 +150,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Problem reading document: " + ex.Message;
|
SetStatusMessage("Problem reading document: " + ex.Message, StatusType.Error);
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logId = id;
|
logId = id;
|
||||||
TempData["StatusMessage"] = "This is the first log for this vehicle";
|
SetStatusMessage("This is the first log for this vehicle");
|
||||||
}
|
}
|
||||||
return RedirectToAction("Details", new {id = logId});
|
return RedirectToAction("Details", new {id = logId});
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
logId = id;
|
logId = id;
|
||||||
TempData["StatusMessage"] = "This is the most recent log for this vehicle";
|
SetStatusMessage("This is the most recent log for this vehicle");
|
||||||
}
|
}
|
||||||
return RedirectToAction("Details", new { id = logId });
|
return RedirectToAction("Details", new { id = logId });
|
||||||
}
|
}
|
||||||
@@ -161,8 +161,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
DataService.AddLog(log);
|
DataService.AddLog(log);
|
||||||
|
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage("Log created", StatusType.Success);
|
||||||
TempData["StatusMessage"] = "Log created";
|
|
||||||
|
|
||||||
if (TempData.ContainsKey("FuelLogId"))
|
if (TempData.ContainsKey("FuelLogId"))
|
||||||
{
|
{
|
||||||
@@ -173,8 +172,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
DataService.UpdateFuelLog(fuelLog);
|
DataService.UpdateFuelLog(fuelLog);
|
||||||
|
|
||||||
// return to the fuel log match page
|
// return to the fuel log match page
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage("Log created and matched to the fuel log", StatusType.Success);
|
||||||
TempData["StatusMessage"] = "Log created and matched to the fuel log";
|
|
||||||
return RedirectToAction("Match", "FuelLog", new {id = fuelLogId});
|
return RedirectToAction("Match", "FuelLog", new {id = fuelLogId});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +211,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
DataService.UpdateLog(log);
|
DataService.UpdateLog(log);
|
||||||
|
|
||||||
TempData["StatusMessage"] = "Log updated";
|
SetStatusMessage("Log updated");
|
||||||
return RedirectToAction("Details", new{id = log.LogId});
|
return RedirectToAction("Details", new{id = log.LogId});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,7 +235,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
DataService.DeleteLog(id);
|
DataService.DeleteLog(id);
|
||||||
|
|
||||||
TempData["StatusMessage"] = "Log deleted";
|
SetStatusMessage("Log deleted");
|
||||||
if (Session["LogPage"] != null)
|
if (Session["LogPage"] != null)
|
||||||
return Redirect((string) Session["LogPage"]);
|
return Redirect((string) Session["LogPage"]);
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
@@ -265,8 +263,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
DataService.FindUserByUsername(viewModel.UserName);
|
DataService.FindUserByUsername(viewModel.UserName);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "User " + viewModel.UserName + " not found";
|
SetStatusMessage("User " + viewModel.UserName + " not found", StatusType.Error);
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -284,13 +281,12 @@ namespace MileageTraker.Web.Controllers
|
|||||||
}
|
}
|
||||||
catch (OutOfMemoryException)
|
catch (OutOfMemoryException)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Problem reading excel document - please verify that the document is in Excel 97-2003 Workbook (.xls) format";
|
SetStatusMessage(
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
"Problem reading excel document - please verify that the document is in Excel 97-2003 Workbook (.xls) format", StatusType.Error);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Problem reading excel document: " + ex.Message;
|
SetStatusMessage("Problem reading excel document: " + ex.Message, StatusType.Error);
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var purposetype = DataService.FindPurposeType(id);
|
var purposetype = DataService.FindPurposeType(id);
|
||||||
if (purposetype == null)
|
if (purposetype == null)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Purpose " + id + " not found";
|
SetStatusMessage("Purpose " + id + " not found");
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
return View(purposetype);
|
return View(purposetype);
|
||||||
@@ -37,7 +37,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
DataService.AddPurposeType(purposetype);
|
DataService.AddPurposeType(purposetype);
|
||||||
|
|
||||||
TempData["StatusMessage"] = "Purpose " + purposetype.Purpose + " created";
|
SetStatusMessage("Purpose " + purposetype.Purpose + " created");
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var purposeType = DataService.FindPurposeType(id);
|
var purposeType = DataService.FindPurposeType(id);
|
||||||
if (purposeType == null)
|
if (purposeType == null)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Purpose " + id + " not found";
|
SetStatusMessage("Purpose " + id + " not found");
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
return View(purposeType);
|
return View(purposeType);
|
||||||
@@ -62,7 +62,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
{
|
{
|
||||||
DataService.UpdatePurposeType(purposeType);
|
DataService.UpdatePurposeType(purposeType);
|
||||||
|
|
||||||
TempData["StatusMessage"] = "Changes to Purpose " + purposeType.Purpose + " saved";
|
SetStatusMessage("Changes to Purpose " + purposeType.Purpose + " saved");
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
return View(purposeType);
|
return View(purposeType);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
DataService.FindUserByUsername(employeeName);
|
DataService.FindUserByUsername(employeeName);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "User " + employeeName + " not found";
|
SetStatusMessage("User " + employeeName + " not found");
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
return View("Details", user);
|
return View("Details", user);
|
||||||
@@ -140,8 +140,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
|
|
||||||
if (viewModel.SetPassword)
|
if (viewModel.SetPassword)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage("User " + user.Username + " created", StatusType.Success);
|
||||||
TempData["StatusMessage"] = "User " + user.Username + " created";
|
|
||||||
return RedirectToAction("SetPassword", new { id = user.UserId });
|
return RedirectToAction("SetPassword", new { id = user.UserId });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,8 +148,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var resetPasswordUrl = ResetPassword(user);
|
var resetPasswordUrl = ResetPassword(user);
|
||||||
email.SendInitializePassword(user, resetPasswordUrl);
|
email.SendInitializePassword(user, resetPasswordUrl);
|
||||||
|
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage("User " + user.Username + " created, invitation sent to " + user.Email, StatusType.Success);
|
||||||
TempData["StatusMessage"] = "User " + user.Username + " created, invitation sent to " + user.Email;
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,7 +173,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var resetPasswordUrl = ResetPassword(user);
|
var resetPasswordUrl = ResetPassword(user);
|
||||||
var email = new EmailNotificationService();
|
var email = new EmailNotificationService();
|
||||||
email.SendResetPassword(user, resetPasswordUrl);
|
email.SendResetPassword(user, resetPasswordUrl);
|
||||||
TempData["StatusMessage"] = "Reset password sent to User " + user.Username + " at " + user.Email;
|
SetStatusMessage("Reset password sent to User " + user.Username + " at " + user.Email);
|
||||||
return RedirectToAction("Details", new { id = userId});
|
return RedirectToAction("Details", new { id = userId});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,7 +229,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
viewModel.Roles.Selected);
|
viewModel.Roles.Selected);
|
||||||
}
|
}
|
||||||
|
|
||||||
TempData["StatusMessage"] = "Changes saved for " + user.Username;
|
SetStatusMessage("Changes saved for " + user.Username);
|
||||||
return RedirectToAction("Details", new { id = viewModel.UserId});
|
return RedirectToAction("Details", new { id = viewModel.UserId});
|
||||||
}
|
}
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
@@ -253,7 +251,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
DataService.UpdateUserPassword(viewModel.UserId, viewModel.NewPassword);
|
DataService.UpdateUserPassword(viewModel.UserId, viewModel.NewPassword);
|
||||||
TempData["StatusMessage"] = "Password set for " + viewModel.Username;
|
SetStatusMessage("Password set for " + viewModel.Username);
|
||||||
return RedirectToAction("Details", new { id = viewModel.UserId});
|
return RedirectToAction("Details", new { id = viewModel.UserId});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,15 +269,14 @@ namespace MileageTraker.Web.Controllers
|
|||||||
}
|
}
|
||||||
if (user.Username == User.Identity.Name)
|
if (user.Username == User.Identity.Name)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage-Type"] = "alert-error";
|
SetStatusMessage("Cannot disable yourself!", StatusType.Error);
|
||||||
TempData["StatusMessage"] = "Cannot disable yourself!";
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
user.IsApproved = false;
|
user.IsApproved = false;
|
||||||
DataService.UpdateUser(user);
|
DataService.UpdateUser(user);
|
||||||
|
|
||||||
TempData["StatusMessage"] = user.Username + " disabled";
|
SetStatusMessage(user.Username + " disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Request.UrlReferrer != null)
|
if (Request.UrlReferrer != null)
|
||||||
@@ -298,7 +295,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
user.IsApproved = true;
|
user.IsApproved = true;
|
||||||
DataService.UpdateUser(user);
|
DataService.UpdateUser(user);
|
||||||
|
|
||||||
TempData["StatusMessage"] = user.Username + " enabled";
|
SetStatusMessage(user.Username + " enabled");
|
||||||
|
|
||||||
if (Request.UrlReferrer != null)
|
if (Request.UrlReferrer != null)
|
||||||
return Redirect(Request.UrlReferrer.AbsolutePath);
|
return Redirect(Request.UrlReferrer.AbsolutePath);
|
||||||
@@ -317,7 +314,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
user.PasswordFailuresSinceLastSuccess = 0;
|
user.PasswordFailuresSinceLastSuccess = 0;
|
||||||
DataService.UpdateUser(user);
|
DataService.UpdateUser(user);
|
||||||
|
|
||||||
TempData["StatusMessage"] = user.Username + " unlocked";
|
SetStatusMessage(user.Username + " unlocked");
|
||||||
|
|
||||||
if (Request.UrlReferrer != null)
|
if (Request.UrlReferrer != null)
|
||||||
return Redirect(Request.UrlReferrer.AbsolutePath);
|
return Redirect(Request.UrlReferrer.AbsolutePath);
|
||||||
|
|||||||
@@ -42,8 +42,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
DataService.AddVehicle(vehicle);
|
DataService.AddVehicle(vehicle);
|
||||||
TempData["StatusMessage"] =
|
SetStatusMessage(string.Format("Vehicle {0} created", vehicle.VehicleId));
|
||||||
string.Format("Vehicle {0} created", vehicle.VehicleId);
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,7 +62,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
if (ModelState.IsValid)
|
if (ModelState.IsValid)
|
||||||
{
|
{
|
||||||
DataService.UpdateVehicle(vehicle);
|
DataService.UpdateVehicle(vehicle);
|
||||||
TempData["StatusMessage"] = "Changes saved for vehicle " + vehicle.VehicleId;
|
SetStatusMessage("Changes saved for vehicle " + vehicle.VehicleId);
|
||||||
return RedirectToAction("Details", new { id = vehicle.VehicleId });
|
return RedirectToAction("Details", new { id = vehicle.VehicleId });
|
||||||
}
|
}
|
||||||
return View(vehicle);
|
return View(vehicle);
|
||||||
@@ -90,13 +89,13 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var vehicle = DataService.GetVehicle(id);
|
var vehicle = DataService.GetVehicle(id);
|
||||||
if (vehicle.InactiveDate.HasValue)
|
if (vehicle.InactiveDate.HasValue)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Vehicle already inactive";
|
SetStatusMessage("Vehicle already inactive");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vehicle.InactiveDate = DateTime.Now;
|
vehicle.InactiveDate = DateTime.Now;
|
||||||
DataService.UpdateVehicle(vehicle);
|
DataService.UpdateVehicle(vehicle);
|
||||||
TempData["StatusMessage"] = string.Format("Vehicle set inactive on {0:MM/dd/yyyy}", vehicle.InactiveDate.Value);
|
SetStatusMessage(string.Format("Vehicle set inactive on {0:MM/dd/yyyy}", vehicle.InactiveDate.Value));
|
||||||
}
|
}
|
||||||
return RedirectToAction("Details", new {id});
|
return RedirectToAction("Details", new {id});
|
||||||
}
|
}
|
||||||
@@ -107,13 +106,13 @@ namespace MileageTraker.Web.Controllers
|
|||||||
var vehicle = DataService.GetVehicle(id);
|
var vehicle = DataService.GetVehicle(id);
|
||||||
if (!vehicle.InactiveDate.HasValue)
|
if (!vehicle.InactiveDate.HasValue)
|
||||||
{
|
{
|
||||||
TempData["StatusMessage"] = "Vehicle is already active";
|
SetStatusMessage("Vehicle is already active");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
vehicle.InactiveDate = null;
|
vehicle.InactiveDate = null;
|
||||||
DataService.UpdateVehicle(vehicle);
|
DataService.UpdateVehicle(vehicle);
|
||||||
TempData["StatusMessage"] = string.Format("Vehicle reactivated");
|
SetStatusMessage(string.Format("Vehicle reactivated"));
|
||||||
}
|
}
|
||||||
return RedirectToAction("Details", new { id });
|
return RedirectToAction("Details", new { id });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,9 +43,8 @@ namespace MileageTraker.Web.Controllers
|
|||||||
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||||
DataService.AddVehicleService(vehicleService);
|
DataService.AddVehicleService(vehicleService);
|
||||||
|
|
||||||
TempData["StatusMessage-Type"] = "alert-success";
|
SetStatusMessage(
|
||||||
TempData["StatusMessage"] =
|
string.Format("Vehicle Service for vehicle {0} created", viewModel.VehicleId), StatusType.Success);
|
||||||
string.Format("Vehicle Service for vehicle {0} created", viewModel.VehicleId);
|
|
||||||
return RedirectToAction("Index");
|
return RedirectToAction("Index");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +69,7 @@ namespace MileageTraker.Web.Controllers
|
|||||||
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
vehicleService.Vehicle = DataService.GetVehicle(viewModel.VehicleId);
|
||||||
|
|
||||||
DataService.UpdateVehicleService(vehicleService);
|
DataService.UpdateVehicleService(vehicleService);
|
||||||
TempData["StatusMessage"] = "Changes saved for vehicle service " + vehicleService.Vehicle.VehicleId;
|
SetStatusMessage("Changes saved for vehicle service " + vehicleService.Vehicle.VehicleId);
|
||||||
return RedirectToAction("Details", new { id = vehicleService.VehicleServiceId });
|
return RedirectToAction("Details", new { id = vehicleService.VehicleServiceId });
|
||||||
}
|
}
|
||||||
return View(viewModel);
|
return View(viewModel);
|
||||||
|
|||||||
Reference in New Issue
Block a user