public ActionResult ChangePassword(ManageUserViewModel model) { var message = ""; DataCollectionModelDataContext db = new DataCollectionModelDataContext(); var RankUser = db.RankUsers.Where(a => a.UserID == SessionManager.UserId.Trim()).FirstOrDefault(); if (RankUser != null) { if (string.Compare(FormCommonMethods.Encryptdata(model.OldPassword), RankUser.UserPassword) == 0) { RankUser.UserPassword = FormCommonMethods.Encryptdata(model.NewPassword); db.SubmitChanges(); message = "Password updated successfully"; //ViewBag.Status = true; //ViewBag.Message = message; TempData["Message"] = message; TempData["Status"] = true; return(Redirect(SessionManager.MenuList.FirstOrDefault().MenuUrl)); } else { message = "Invalid Old Password"; ViewBag.Status = false; } } ViewBag.Message = message; return(View(model)); }
public ActionResult EditUserDetail(string UserId) { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); RankUserViewModel rankUserViewModel = new RankUserViewModel(); RankUser RankUser = db.RankUsers.Where(a => a.UserID == UserId).FirstOrDefault(); rankUserViewModel.RankUser = FormCommonMethods.ToEntityRankUserMap(RankUser); rankUserViewModel.MenuList = (from post in db.UserMenus join menu in db.MenuIDs on post.MenuID equals menu.MenuID1 where post.UserID == UserId select menu.MenuID1).ToArray(); rankUserViewModel.MenuDDLList = db.MenuIDs.Where(a => !(a.IsAdminMenu ?? false)).Select(i => new SelectListItem() { Text = i.MenuDetails, Value = i.MenuID1, Selected = rankUserViewModel.MenuList.Contains(i.MenuID1) }).AsEnumerable(); rankUserViewModel.UserRoleDDLList = db.UserRoles.Select(i => new SelectListItem() { Text = i.UserRoleDetails, Value = i.UserRole1 }).AsEnumerable(); rankUserViewModel.UserWorkDDLList = db.UserWorks.Select(i => new SelectListItem() { Text = i.UserWorkDetails, Value = i.UserWork1 }).AsEnumerable(); rankUserViewModel.DeptDDLList = db.Depts.Select(i => new SelectListItem() { Text = i.DeptName, Value = i.DeptID }).AsEnumerable(); return(PartialView("EditUserPartial", rankUserViewModel)); }
// // GET: /Admin/ public ActionResult Index() { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); IEnumerable <DataCollection.Models.RankUser> RankUser = db.RankUsers.Where(a => (a.DeptID.ToLower().Trim() != "admin" || a.DeptID == null) && a.IsEmailVerified == true).ToList(); return(View(RankUser)); }
public JsonResult GetDepartmentList() { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); var DeptDDLList = db.Depts.Select(i => new { Text = i.DeptName, Value = i.DeptID }).AsEnumerable(); return(Json(DeptDDLList, JsonRequestBehavior.AllowGet)); }
public bool SaveRankMessage(string RankMessageId, string RankMessage) { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); try { if (Convert.ToInt32(RankMessageId) > 0) { var RankMesgs = db.RankMesgs.Where(a => a.Id == Convert.ToInt32(RankMessageId)).FirstOrDefault(); if (RankMesgs != null) { RankMesgs.Message = RankMessage; } db.SubmitChanges(); } else { RankMesg rankMesgs = new RankMesg(); rankMesgs.Message = RankMessage; db.RankMesgs.InsertOnSubmit(rankMesgs); db.SubmitChanges(); } return(true); } catch { return(false); } }
public JsonResult DofaPeerAutoComplete(string EmpNo) //, string DataCaptYM { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); //int dataCaptYM = 0; //int.TryParse(DataCaptYM, out dataCaptYM); var dofaInfos = (from dofa in db.dofaInfos where dofa.empNo.ToString().ToLower().Trim().Equals(EmpNo.ToLower().Trim()) //&& dofa.DataCaptYM == dataCaptYM && dofa.DeptID == SessionManager.DeptID && dofa.MenuID == DataAccess.Enum.Menu.DOFA.ToString() select new { empNo = dofa.empNo, empDEPT = dofa.empDEPT, empName = dofa.empName, dataCaptYM = dofa.DataCaptYM }).FirstOrDefault(); object dofaa = new object(); if (dofaInfos != null) { dofaa = new { dataCaptYM = dofaInfos.dataCaptYM, empNo = dofaInfos.empNo, empDEPT = dofaInfos.empDEPT, empName = dofaInfos.empName, isEmpFound = true }; } else { dofaa = new { isEmpFound = false }; } return(Json(dofaa, JsonRequestBehavior.AllowGet)); }
public static bool SendEmailOnSaveForDOFAPeer(string Action, int EmpNo, string EmpName) { string subject = "IRD Data Entry updated by " + SessionManager.UserName; DataCollectionModelDataContext db = new DataCollectionModelDataContext(); string tomail = "*****@*****.**"; string body = string.Empty; if (Action == "Save") { body = "Peer List Added/Updated For EmpNo:" + EmpNo + "<br /> EmpName:" + EmpName + " On " + DateTime.Now.ToString() + " by User: "******"", subject, body)); } else { return(true); } }
public static List <SelectListItem> GetDeptDropdownData(string deptName) { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); List <SelectListItem> DeptDDLList = new List <SelectListItem>() { new SelectListItem() { Text = "-- Select --", Value = "" } }; if (deptName == "DFNP") { DeptDDLList.AddRange(db.Depts.Select(i => new SelectListItem { Text = i.DeptName, Value = i.DeptID })); } else { DeptDDLList.Add(new SelectListItem() { Text = "DOAA", Value = "DOAA" }); DeptDDLList.AddRange(db.Depts.Where(w => w.DeptType == 'A').Select(i => new SelectListItem { Text = i.DeptName, Value = i.DeptID })); } return(DeptDDLList); }
public ActionResult ResetPassword(string id) { //Verify the reset password link //Find account associated with this link //redirect to reset password page if (string.IsNullOrWhiteSpace(id)) { return(HttpNotFound()); } using (DataCollectionModelDataContext db = new DataCollectionModelDataContext()) { var user = db.RankUsers.Where(a => a.ResetPasswordCode == id).FirstOrDefault(); if (user != null) { ResetPasswordModel model = new ResetPasswordModel(); model.ResetCode = id; return(View(model)); } else { return(RedirectToAction("Login", "User", null)); } } }
public ActionResult ResetPassword(ResetPasswordModel model) { var message = ""; if (ModelState.IsValid) { using (DataCollectionModelDataContext db = new DataCollectionModelDataContext()) { var user = db.RankUsers.Where(a => a.ResetPasswordCode == model.ResetCode).FirstOrDefault(); if (user != null) { user.UserPassword = FormCommonMethods.Encryptdata(model.NewPassword); user.ResetPasswordCode = ""; db.SubmitChanges(); message = "New password updated successfully"; //ViewBag.Status = true; //ViewBag.Message = message; TempData["Message"] = message; TempData["Status"] = true; return(RedirectToAction("Login", "User", null)); } } } else { message = "invalid details. Contact System Administrator."; ViewBag.Status = false; } ViewBag.Message = message; return(View(model)); }
//[ValidateAntiForgeryToken] public ActionResult Login(LoginViewModel loginViewModel, string ReturnUrl = "") { string message = ""; using (DataCollectionModelDataContext db = new DataCollectionModelDataContext()) { DataCollection.Models.RankUser RankUser = db.RankUsers.Where(a => a.UserID == loginViewModel.UserId.Trim()).FirstOrDefault(); if (RankUser != null) { if (string.Compare(FormCommonMethods.Encryptdata(loginViewModel.Password), RankUser.UserPassword) == 0) { if (string.IsNullOrWhiteSpace(Convert.ToString(RankUser.UserValid)) || Convert.ToString(RankUser.UserValid).ToUpper().Trim() == "N" || (string.IsNullOrWhiteSpace(RankUser.DeptID) || string.IsNullOrWhiteSpace(RankUser.UserRole) || string.IsNullOrWhiteSpace(RankUser.UserWork))) { if (Convert.ToString(RankUser.UserValid).ToUpper().Trim() == "N" && RankUser.UserDisabledOn != null) { ViewBag.Message = "Your account is blocked. Please Contact Admin"; ViewBag.Status = false; } else if (Convert.ToString(RankUser.UserValid).ToUpper().Trim() == "N" && (!RankUser.IsEmailVerified ?? !false)) { ViewBag.Message = "Email link sent. kindly click on the link to complete registration"; ViewBag.Status = false; } else if (Convert.ToString(RankUser.UserValid).ToUpper().Trim() == "N" && (RankUser.IsEmailVerified ?? false)) { string href = Url.Action("Index", "Contact", null); var link = Request.Url.AbsoluteUri.Replace(Request.Url.PathAndQuery, href); ViewBag.Message = "Activation pending from Admin , IRD-SRIC. Kindly wait for some more time or Contact through <a href='" + link + "'> Contact Us </a>"; ViewBag.Status = false; } return(View()); } int timeout = loginViewModel.RememberMe ? 525600 : 20; // 525600 min = 1 year FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, RankUser.UserName, DateTime.Now, DateTime.Now.AddMinutes(2880), loginViewModel.RememberMe, RankUser.UserRole, FormsAuthentication.FormsCookiePath); string encrypted = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); cookie.HttpOnly = true; Response.Cookies.Add(cookie); SetUserSession(RankUser); ViewBag.Status = true; return(Redirect(SessionManager.MenuList.FirstOrDefault().MenuUrl)); } else { message = "Invalid credential provided"; ViewBag.Status = false; } } else { message = "Invalid credential provided"; ViewBag.Status = false; } } ViewBag.Message = message; return(View()); }
public ActionResult ForgotPassword(string EmailID) { //Verify Email ID //Generate Reset password link //Send Email string message = ""; bool status = false; using (DataCollectionModelDataContext db = new DataCollectionModelDataContext()) { var account = db.RankUsers.Where(a => a.UserEmail == EmailID).FirstOrDefault(); if (account != null) { //Send email for reset password string resetCode = Guid.NewGuid().ToString(); SendVerificationLinkEmail(account.UserEmail, resetCode, "ResetPassword"); account.ResetPasswordCode = resetCode; //This line I have added here to avoid confirm password not match issue , as we had added a confirm password property //in our model class in part 1 db.SubmitChanges(); ModelState.Clear(); message = "Reset password link has been sent to your email id."; status = true; } else { message = "Account not found"; } } ViewBag.Message = message; ViewBag.Status = status; return(View()); }
public ActionResult RankMessage() { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); RankMessageViewModel rankMessageViewModel = new RankMessageViewModel(); var RankMesgs = db.RankMesgs.FirstOrDefault(); if (RankMesgs != null) { rankMessageViewModel.RankMessageId = RankMesgs.Id; rankMessageViewModel.RankMessage = RankMesgs.Message; } return(View(rankMessageViewModel)); }
public ActionResult Table() { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); var AllTables = db.Get_All_Table().ToList(); TableViewModel TableViewModel = new TableViewModel(); TableViewModel.Tables = AllTables.Select(i => new SelectListItem() { Text = i.Name, Value = i.Name }).AsEnumerable(); return(View(TableViewModel)); }
public ActionResult Login(LoginViewModel loginViewModel, string ReturnUrl = "") { string message = ""; using (DataCollectionModelDataContext db = new DataCollectionModelDataContext()) { DataCollection.Models.RankUser RankUser = db.RankUsers.Where(a => a.UserID == loginViewModel.UserId.Trim()).FirstOrDefault(); if (RankUser != null) { if (string.Compare(FormCommonMethods.Encryptdata(loginViewModel.Password), RankUser.UserPassword) == 0) { if (string.IsNullOrWhiteSpace(Convert.ToString(RankUser.UserValid)) || Convert.ToString(RankUser.UserValid).ToUpper().Trim() == "N" || (string.IsNullOrWhiteSpace(RankUser.DeptID) || string.IsNullOrWhiteSpace(RankUser.UserRole) || string.IsNullOrWhiteSpace(RankUser.UserWork))) { if (Convert.ToString(RankUser.UserValid).ToUpper().Trim() == "N" && RankUser.UserDisabledOn != null) { ViewBag.Message = "Your account is blocked. Please Contact Admin"; } else { ViewBag.Message = "Your registration is under process"; } return(View()); } int timeout = loginViewModel.RememberMe ? 525600 : 20; // 525600 min = 1 year FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, RankUser.UserName, DateTime.Now, DateTime.Now.AddMinutes(2880), loginViewModel.RememberMe, RankUser.UserRole, FormsAuthentication.FormsCookiePath); string encrypted = FormsAuthentication.Encrypt(ticket); var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted); cookie.Expires = DateTime.Now.AddMinutes(timeout); cookie.HttpOnly = true; Response.Cookies.Add(cookie); SetUserSession(RankUser); ViewBag.Status = true; return(Redirect(SessionManager.MenuList.FirstOrDefault().MenuUrl)); } else { message = "Invalid credential provided"; ViewBag.Status = false; } } else { message = "Invalid credential provided"; ViewBag.Status = false; } } ViewBag.Message = message; return(View()); }
public ActionResult VerifyAccount(string id) { bool Status = false, IsLoginLinkVisible = false; if (string.IsNullOrEmpty(id)) { return(RedirectToAction("Login", "User", null)); } using (DataCollectionModelDataContext db = new DataCollectionModelDataContext()) { Guid guidResult; bool isValid = Guid.TryParse(id, out guidResult); if (!isValid) { return(RedirectToAction("Login", "User", null)); } var v = db.RankUsers.Where(a => a.ActivationCode == new Guid(id)).FirstOrDefault(); if (v != null) { if (!v.IsEmailVerified ?? false) { v.IsEmailVerified = true; db.SubmitChanges(); Status = true; ViewBag.Message = "Your registered details has been verified successfully. Your account will be activated after authorisation by administrator(IRD-SRIC)."; } else if (v.UserValid.ToString().ToUpper() == "N" && v.UserDisabledOn == null) { Status = true; ViewBag.Message = "Your registered details have been already verified. Please wait for authorisation by administrator(IRD-SRIC)"; } else if (v.UserValid.ToString().ToUpper() == "Y") { ViewBag.Message = "Your registered details have been already verified. Please wait for authorisation by administrator(IRD-SRIC)"; IsLoginLinkVisible = true; } } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = Status; ViewBag.IsLoginLinkVisible = IsLoginLinkVisible; return(View()); }
public RegisterViewModel LoadRegister() { RegisterViewModel registerViewModel = new RegisterViewModel(); DataCollectionModelDataContext db = new DataCollectionModelDataContext(); registerViewModel.UserWorkDDLList = db.UserWorks.Where(a => a.UserWork1.ToLower().Trim() != "admin").Select(i => new SelectListItem() { Text = i.UserWorkDetails, Value = i.UserWork1 }).AsEnumerable(); registerViewModel.DeptDDLList = db.Depts.Select(i => new SelectListItem() { Text = i.DeptName, Value = i.DeptID }).AsEnumerable(); return(registerViewModel); }
public static List <MenuID> GetCurrentUserMenu(string UserID, string UserRole) { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); if (UserRole.ToLower().Trim() == UserRoles.Admin.ToString().ToLower()) { return(db.MenuIDs.ToList()); } else { return((from menu in db.MenuIDs join um in db.UserMenus on menu.MenuID1 equals um.MenuID where um.UserID == UserID select menu).ToList()); } }
public static List <MenuID> GetCurrentUserMenu(string UserID, string UserRole) { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); var UserMenu = db.UserMenus.Where(UID => UID.UserID.ToLower().Equals(UserID.ToLower()) && UID.MenuID.ToLower().Equals("all")).ToList(); if (UserMenu.Count > 0) { if (UserID.ToLower().Equals(UserRoles.Admin.ToString().ToLower())) { return(db.MenuIDs.ToList()); } else { return(db.MenuIDs.Where(a => a.MenuID1 != "USERS" && a.MenuID1 != "REPORTS" && a.MenuID1 != "" && a.MenuID1 != "TABLE" && a.MenuID1 != "MESSAGE").ToList()); } } else { return((from menu in db.MenuIDs join um in db.UserMenus on menu.MenuID1 equals um.MenuID where um.UserID == UserID select menu).ToList()); } }
public static DataCollection.Models.RankMesg GetCurrentRankMesg() { DataCollectionModelDataContext db = new DataCollectionModelDataContext(); return(db.RankMesgs.FirstOrDefault()); }
public static bool SendFinallizeEmail(string Action, int DataCaptYM, string DeptId, string needModificationMSG) { string subject = "IRD Data Entry updated by " + SessionManager.UserName; DataCollectionModelDataContext db = new DataCollectionModelDataContext(); string tomail = "*****@*****.**"; string body = string.Empty; if (Action == "Finalize" || Action == "FinalizedByHod" || Action == "FinalizedByAssoDean") { body = "The User: "******", Dept: " + DeptId + " , DataCapt: " + DataCaptYM + ", IRD Data has been finalised & sent for your Authorization. Kindly Check & Authorize/Approve the data." + "Time Stamp: DateTime Stamp: " + DateTime.Now + "This is a System generated Email."; } else if (Action == "ModificationNeededHod" || Action == "ModificationNeededADean" || Action == "ModificationNeededDean") { body = "The User: "******", Dept: " + DeptId + " , DataCapt: " + DataCaptYM + ", IRD Data has been sent for Modification. Kindly Check Modification Note for data changes. <br /> Modification Note: " + needModificationMSG + "Time Stamp: DateTime Stamp: " + DateTime.Now + "<br /> This is a System generated Email."; } if (Action == "Finalize") { var hod = db.RankUsers.Where(a => a.DeptID.ToLower() == SessionManager.DeptID.ToLower() && a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.HOD.ToString().ToLower()).FirstOrDefault(); if (hod != null) { tomail = hod.UserEmail; } } else if (Action == "FinalizedByHod") { var adsric = db.RankUsers.Where(a => a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.ADSRIC.ToString().ToLower()).FirstOrDefault(); if (adsric != null) { tomail = adsric.UserEmail; } } else if (Action == "FinalizedByAssoDean") { var dsric = db.RankUsers.Where(a => a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.DSRIC.ToString().ToLower()).FirstOrDefault(); if (dsric != null) { tomail = dsric.UserEmail; } } else if (Action == "ModificationNeededHod") { var doModification = db.RankUsers.Where(a => a.DeptID.ToLower() == SessionManager.DeptID.ToLower() && a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.DO.ToString().ToLower()).ToList(); if (doModification != null && doModification.Count > 0) { tomail = string.Join(",", doModification.Select(i => i.UserEmail)); } } else if (Action == "ModificationNeededADean") { var hodModification = db.RankUsers.Where(a => a.DeptID.ToLower() == SessionManager.DeptID.ToLower() && a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.HOD.ToString().ToLower()).FirstOrDefault(); if (hodModification != null) { tomail = hodModification.UserEmail; } } else if (Action == "ModificationNeededDean") { var adeanModification = db.RankUsers.Where(a => a.UserRole.ToLower() == UserRoles.User.ToString().ToLower() && a.UserWork.ToLower() == DataAccess.Enum.UserWork.ADSRIC.ToString().ToLower()).FirstOrDefault(); if (adeanModification != null) { tomail = adeanModification.UserEmail; } } if (!string.IsNullOrEmpty(body)) { body = body.Replace("\r\n", "<br />"); FormServices formServices = new FormServices(); return(formServices.SendEmail(tomail, "", subject, body)); } else { return(true); } }
public ActionResult UpdateUserDetail(RankUserViewModel rankUserViewModel, string[] MenuList) { bool Status = false; DataCollectionModelDataContext db = new DataCollectionModelDataContext(); RankUser rankUser = db.RankUsers.Where(a => a.UserID == rankUserViewModel.RankUser.UserID).FirstOrDefault(); if (rankUser != null) { rankUser.DeptID = rankUserViewModel.RankUser.DeptID; rankUser.UserDisabledOn = Convert.ToString(rankUserViewModel.RankUser.UserValid) == "N" ? DateTime.Now : (DateTime?)null; rankUser.UserEmail = rankUserViewModel.RankUser.UserEmail; rankUser.UserEmpNo = rankUserViewModel.RankUser.UserEmpNo; rankUser.UserMob = rankUserViewModel.RankUser.UserMob; rankUser.UserName = rankUserViewModel.RankUser.UserName; rankUser.UserRole = rankUserViewModel.RankUser.UserRole; rankUser.UserValid = Convert.ToChar(rankUserViewModel.RankUser.UserValid ?? null); rankUser.UserWork = rankUserViewModel.RankUser.UserWork; db.Connection.Open(); using (db.Transaction = db.Connection.BeginTransaction()) { try { IEnumerable <UserMenu> userMenu = db.UserMenus.Where(a => a.UserID == rankUserViewModel.RankUser.UserID).ToList(); if (userMenu != null) { var sa = userMenu.Where(a => !MenuList.Contains(a.MenuID)).ToList(); if (sa.Any()) { db.UserMenus.DeleteAllOnSubmit(sa); } } List <UserMenu> userMenuList = new List <UserMenu>(); foreach (string item in MenuList) { var sa = userMenu.Where(a => a.MenuID == item).FirstOrDefault(); if (sa == null) { UserMenu menu = new UserMenu(); menu.MenuID = item; menu.UserID = rankUserViewModel.RankUser.UserID; userMenuList.Add(menu); } } if (userMenuList.Any()) { db.UserMenus.InsertAllOnSubmit(userMenuList); } db.SubmitChanges(); db.Transaction.Commit(); Status = true; ViewBag.Message = "User Updated Successfully."; ViewBag.Status = true; try { if (rankUserViewModel.RankUser.UserValid == "Y") { string body = "Dear " + rankUserViewModel.RankUser.UserName + ",<br /> You have been authorised by admin now. You can access the system by logging in. <br /><br /> Admin <br /> IRD SRIC"; FormServices formServices = new FormServices(); body = body.Replace("\r\n", "<br />"); string subject = "User Authorised by Admin, IRD-SRIC, IITR"; formServices.SendEmail(rankUserViewModel.RankUser.UserEmail, "", subject, body); } } catch (Exception ex) { } } catch (Exception ex) { db.Transaction.Rollback(); ViewBag.Message = "Failed To Updated User. Error: " + ex.Message; ViewBag.Status = false; } } } return(Json(new { success = Status })); }