//----------------------------------------------------------------------- // // Copyright (c) CCPL. All rights reserved. // // Jitendra Tiwari //-------------------------------- namespace WEBAPP._2012.Controllers { using LoggingHelper; using System; using System.Configuration; using System.Web.Mvc; using GODATA.AuthenticationServices; using GODATA.Models; /// /// Class for user management. /// /// [GODATA.MvcApplication.SessionExpire] public class UserController : Controller { #region Global Variables /// /// Represent object of LoggingUtility class /// LoggingUtility objLog = new LoggingUtility(); /// /// Represent string object contain log file path /// string path = System.Web.HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["PathLog"]); /// /// Represent string object contain log status /// string logtf = (ConfigurationManager.AppSettings["Log"]); /// /// Represent string object contain Error log status /// string errorlogtf = (ConfigurationManager.AppSettings["ErrorLog"]); /// /// it's get application name from web.config file. /// private static string _appName = ConfigurationManager.AppSettings["ApplicationName"].ToString(); #endregion /// /// GET : User/Index /// /// Action Result public ActionResult Index() { return View(); } #region Actions - Change Password /// /// GET: /Account/ChangePassword /// /// Action Result public ActionResult ChangePassword() { return View(); } /// /// POST: /Account/ChangePassword /// /// Change Password Model /// Action Result [HttpPost] public ActionResult ChangePassword(ChangePasswordModel model) { objLog.AddLogFile("ChangePassword", DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); if (ModelState.IsValid) { bool changePasswordSucceeded; try { UserClient oUserClient = new UserClient(); changePasswordSucceeded = oUserClient.ChangePasswordByApplication(User.Identity.Name, model.OldPassword, model.NewPassword, _appName); } catch (Exception ex) { changePasswordSucceeded = false; objLog.ErrorLogFile("ChangePassword", ex.Message, path, errorlogtf); objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); ModelState.AddModelError(string.Empty, ex.Message); } if (changePasswordSucceeded) { objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return RedirectToAction("ChangePasswordSuccess"); } else { objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); ModelState.AddModelError(string.Empty, "The current password is incorrect or the new password is invalid."); } } ////If we got this far, something failed, redisplay form objLog.AddLogFile(DateTime.Now.ToString(ConfigurationManager.AppSettings["dateTimeFormat"]), path, logtf); return View(model); } /// /// GET: /Account/ChangePasswordSuccess /// /// Action Result public ActionResult ChangePasswordSuccess() { return View(); } #endregion } }