public ActionResult LogOff() { UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { USERLOGIN temp = uluow.Context.UserLogins.Where(f => f.UserName == User.Identity.Name).OrderByDescending(f => f.LOGINTIME).FirstOrDefault(); if (temp != null) { temp.LOGOUTTIME = DateTime.UtcNow; temp.STATUS = "A"; temp.MODIFIEDBY = User.Identity.Name; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Modified; repo.InsertOrUpdate(temp); uluow.Save(); } } FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); }
public JsonResult LogOnOuter(LogOnModel model, string returnUrl) { Session["Gridresult"] = null; try { if (ModelState.IsValid) { var data = uow.Context.UserInformations.SingleOrDefault(f => f.UserName == model.UserName); if (data == null) { return(Json(new { msg = "The user name not found" }, JsonRequestBehavior.AllowGet)); } if (data.IsApproved) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { if (data != null) { if (data.USERTYPE == "P") { FormsService.SignIn(model.UserName, model.RememberMe); if (true) { UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { Session["PatientID"] = model.UserName; USERLOGIN temp = new USERLOGIN(); temp.LOGINTIME = DateTime.UtcNow; temp.DateCreated = DateTime.UtcNow; temp.CREATEDBY = model.UserName; temp.UserName = model.UserName; temp.STATUS = "A"; temp.MODIFIEDBY = model.UserName; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Added; repo.InsertOrUpdate(temp); uluow.Save(); } } } else { return(Json(new { msg = "Account type not valid" }, JsonRequestBehavior.AllowGet)); } } } else { return(Json(new { msg = "The user name or password provided is incorrect." }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { msg = "Please Activate your account from your Email-id doccare registration message." }, JsonRequestBehavior.AllowGet)); } } } catch (Exception ex) { throw new CustomException("Exception:- Project: {0} \n Error Message: {1} ", ex.InnerException, new Object[] { ex.Source, ex.Message }); } return(Json(new { msg = "success" }, JsonRequestBehavior.AllowGet)); }
public ActionResult LogOn(LogOnModel model, string returnUrl) { Session["Gridresult"] = null; try { if (ModelState.IsValid) { var data = uow.Context.UserInformations.SingleOrDefault(f => f.UserName == model.UserName); if (data == null) { ModelState.AddModelError("", "The user name not found."); return(View(model)); } if (data.IsApproved) { if (MembershipService.ValidateUser(model.UserName, model.Password)) { if (data != null) { if (data.USERTYPE == "D") { FormsService.SignIn(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { Session["DoctorId"] = User.Identity.Name; UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { USERLOGIN temp = new USERLOGIN(); temp.LOGINTIME = DateTime.UtcNow; temp.DateCreated = DateTime.UtcNow; temp.CREATEDBY = model.UserName; temp.UserName = model.UserName; temp.STATUS = "A"; temp.MODIFIEDBY = model.UserName; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Added; repo.InsertOrUpdate(temp); uluow.Save(); } if (data.IsfirstLogin.Trim() == "false") { return(RedirectToAction("Dashboard", "DoctorInformation")); } else { return(RedirectToAction("Welcomepage", "DoctorInformation")); } } } else if (data.USERTYPE == "P") { FormsService.SignIn(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } else { Session["PatientId"] = User.Identity.Name; UserLoginsUnitOfWork uluow = new UserLoginsUnitOfWork(); using (var repo = new UserLoginsServiceRepository(uluow)) { USERLOGIN temp = new USERLOGIN(); temp.LOGINTIME = DateTime.UtcNow; temp.DateCreated = DateTime.UtcNow; temp.CREATEDBY = model.UserName; temp.UserName = model.UserName; temp.STATUS = "A"; temp.MODIFIEDBY = model.UserName; temp.MODIFIEDON = DateTime.UtcNow; temp.State = State.Added; repo.InsertOrUpdate(temp); uluow.Save(); } if (data.IsfirstLogin.Trim() == "false") { return(RedirectToAction("Dashboard", "PatientProfile")); } else { return(RedirectToAction("Welcomepage", "PatientProfile")); } } } else if (data.USERTYPE == "A") { FormsService.SignIn(model.UserName, model.RememberMe); if (Url.IsLocalUrl(returnUrl)) { return(Redirect(returnUrl)); } return(RedirectToAction("AccountAdmin", "AccountSettings")); } } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } else { ModelState.AddModelError("", "Please Activate your account from your Email-id doccare registration message."); } } } catch (Exception ex) { throw new CustomException("Exception:- Project: {0} \n Error Message: {1} ", ex.InnerException, new Object[] { ex.Source, ex.Message }); } // If we got this far, something failed, redisplay form return(View(model)); }