public ActionResult ResetPassword(string EncryptUserClientId, ClientChangePassword ObjModel) { if (ModelState.IsValidField("NewPassword") && ModelState.IsValidField("ConfirmPassword")) { EncryptUserClientId = EncryptUserClientId.Replace("$", "+"); EncryptUserClientId = EncryptUserClientId.Replace("/", "!"); Encrypt64 encrypt = new Encrypt64(); string UserClientId = encrypt.Decrypt(EncryptUserClientId, ConfigurationManager.AppSettings["SecureKey"].ToString()); ObjModel.UserClientId = Convert.ToInt32(UserClientId); ClientLoginHelper clientLoginHelper = new ClientLoginHelper(); ClientLogOnModel clientLogOnModel = new ClientLogOnModel(); clientLogOnModel = clientLoginHelper.GetById(ObjModel.UserClientId); int Result = clientLoginHelper.ForgotChangePassword(ObjModel); if (Result == 0) { TempData["CommonMessage"] = AppLogic.setMessage(0, "Password changed sucessfully"); return(Redirect(Url.Content("~/" + clientLogOnModel.StrataPortalLink + "/Login"))); } else { TempData["CommonMessage"] = AppLogic.setMessage(1, "Please check password you have entered and Try again"); return(View()); } } else { return(View()); } }
/// <summary> /// Used to Authenticate Client User /// </summary> /// <param name="objModel"></param> /// <param name="result"></param> /// <returns></returns> public DataTable AuthenticateClientUser(ClientLogOnModel objModel, out int result) { try { objModel.Password = AppLogic.EncryptPasswordString(objModel.Password); result = -1; _conString = SqlHelper.GetConnectionString(); SqlParameter prmEmail = SqlHelper.CreateParameter("@EmailId", objModel.Email); SqlParameter prmPassword = SqlHelper.CreateParameter("@Password", objModel.Password); SqlParameter prmType = SqlHelper.CreateParameter("@Type", 1); SqlParameter prmErr = SqlHelper.CreateParameter("@Err", -1, ParameterDirection.Output); SqlParameter[] allParams = { prmEmail, prmPassword, prmType, prmErr }; DataSet ds = SqlHelper.ExecuteDataset(_conString, CommandType.StoredProcedure, "Usp_GetClientUser", allParams); if (prmErr.Value != null) { result = (int)prmErr.Value; } if (ds != null && ds.Tables.Count > 0) { DataTable Dt = ds.Tables[0].Copy(); ds.Dispose(); return(Dt); } else { return((DataTable)null); } } catch { throw; } }
// GET: Settings/MyProfile public ActionResult MyProfile() { if (ClientSessionData.UserClientId != 0) { model = clientLoginHelper.GetById(ClientSessionData.UserClientId); } return(View(model)); }
public ActionResult CompleteProfile() { ClientLogOnModel model = new ClientLogOnModel(); if (ClientSessionData.UserClientId != 0) { model = clientLoginHelper.GetById(ClientSessionData.UserClientId); } return(View(model)); }
public ActionResult UniqueURLRequest() { RequestPortalLinkModel model = new RequestPortalLinkModel(); if (ClientSessionData.UserClientId != 0) { StrataBoardHelper strataBoardHelper = new StrataBoardHelper(); model = strataBoardHelper.GetStratasBoardPortalLinkDetails(ClientSessionData.ClientStrataBoardId); } return(View(model)); }
// GET: DashBoard public ActionResult Index() { ClientLogOnModel model = new ClientLogOnModel(); ClientLoginHelper clientLoginHelper = new ClientLoginHelper(); if (ClientSessionData.UserClientId != 0) { model = clientLoginHelper.GetById(ClientSessionData.UserClientId); } return(View(model)); }
public int UpdateProfile(ClientLogOnModel clientLogOnModel, bool IsOwner) { if (ClientSessionData.UserClientId != 0) { try { var userClient = _context.tblUserClients.Where(x => x.UserClientId == ClientSessionData.UserClientId).FirstOrDefault(); userClient.FirstName = clientLogOnModel.FirstName; userClient.LastName = clientLogOnModel.LastName; if (!string.IsNullOrEmpty(clientLogOnModel.ProfilePicture)) { userClient.ProfilePicture = clientLogOnModel.ProfilePicture; } if (IsOwner) { userClient.ContactNumber = clientLogOnModel.ContactNumber; userClient.PremiseType = clientLogOnModel.PremiseType; userClient.LeaseCommenceDate = string.IsNullOrEmpty(clientLogOnModel.LeaseCommenceDate) ? (DateTime?)null : Convert.ToDateTime(clientLogOnModel.LeaseCommenceDate); userClient.LeaseEndDate = string.IsNullOrEmpty(clientLogOnModel.LeaseEndDate) ? (DateTime?)null : Convert.ToDateTime(clientLogOnModel.LeaseEndDate); userClient.UnitNumber = clientLogOnModel.UnitNumber; } _context.Entry(userClient).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); ClientSessionData.ClientName = userClient.FirstName + " " + userClient.LastName; ClientSessionData.ClientProfilePicture = userClient.ProfilePicture; return(1); } catch { return(0); } } else { return(0); } }
public ClientLogOnModel GetById(int userClientId) { try { var objMember = _context.tblUserClients.Where(x => x.UserClientId == userClientId).FirstOrDefault(); ClientLogOnModel userClient = new ClientLogOnModel { UserClientId = objMember.UserClientId, FirstName = objMember.FirstName, LastName = objMember.LastName, Email = objMember.EmailId, ContactNumber = objMember.ContactNumber, StratasBoardId = objMember.StratasBoardId, RoleName = objMember.RoleName, PremiseType = objMember.PremiseType, ProfilePicture = objMember.ProfilePicture, OldProfilePicture = objMember.ProfilePicture, LeaseCommenceDate = objMember.LeaseCommenceDate != null?objMember.LeaseCommenceDate.Value.ToShortDateString() : "", LeaseEndDate = objMember.LeaseEndDate != null?objMember.LeaseEndDate.Value.ToShortDateString() : "", UnitNumber = objMember.UnitNumber, IsProfileComplete = objMember.IsProfileComplete, StrataBoardName = objMember.tblStratasBoard.StratasBoardName, BuildingName = objMember.tblStratasBoard.BuildingName, IsSMSNotification = objMember.IsSMSNotification, IsEmailNotification = objMember.IsEmailNotification, StrataPortalLink = objMember.tblStratasBoard.PortalLink }; return(userClient); } catch { return(new ClientLogOnModel()); } }
public ActionResult MyProfile(ClientLogOnModel model) { if (ClientSessionData.UserClientId != 0) { try { var imageTypes = new string[] { "image/png", "image/jpeg", "image/pjpeg" }; int _maxLength = MaxProfileImageLength * 1024 * 1024; ModelState.Remove("ImageType"); if (model.ImageType != null) { if (!imageTypes.Contains(model.ImageType.ContentType)) { ModelState.AddModelError("ImageType", "Please choose either a JPG or PNG image."); } else if (model.ImageType.ContentLength > _maxLength) { ModelState.AddModelError("ImageType", "Maximum allowed file size is " + MaxProfileImageLength + " MB."); } else if (imageTypes.Contains(model.ImageType.ContentType) && model.ImageType.ContentLength <= _maxLength) { System.Drawing.Image img = System.Drawing.Image.FromStream(model.ImageType.InputStream); int height = img.Height; int width = img.Width; if (width > MaxProfileImageWidth || height > MaxProfileImageHeight) { ModelState.AddModelError("ImageType", "Maximum allowed file dimension is " + MaxProfileImageWidth + "*" + MaxProfileImageHeight); } } } if (ModelState.IsValidField("FirstName") && ModelState.IsValidField("LastName")) { int result = 0; if (model.ImageType != null) { string ext = System.IO.Path.GetExtension(model.ImageType.FileName); model.ProfilePicture = Guid.NewGuid() + ext; string path = "~/Content/Resources/Stratabaord/" + ClientSessionData.ClientStrataBoardId + "/profileimages/"; if (!Directory.Exists(Server.MapPath(path))) { Directory.CreateDirectory(Server.MapPath(path)); } string Mappedpath = Server.MapPath(path + model.ProfilePicture); result = clientLoginHelper.UpdateProfile(model, false); if (result == 1) { // save the file locally model.ImageType.SaveAs(Mappedpath); // save the file on s3 int fileMapped = AwsS3Bucket.CreateFile("resources/stratabaord/" + ClientSessionData.ClientStrataBoardId + "/profileimages/" + model.ProfilePicture, Mappedpath); // delete the file locally if (System.IO.File.Exists(Mappedpath)) { System.IO.File.Delete(Mappedpath); } string OldProfilePath = Server.MapPath(path + model.OldProfilePicture); if (System.IO.File.Exists(OldProfilePath)) { System.IO.File.Delete(OldProfilePath); } // delete the old file from s3 AwsS3Bucket.DeleteObject("resources/stratabaord/" + ClientSessionData.ClientStrataBoardId + "/profileimages/" + model.OldProfilePicture); TempData["CommonMessage"] = AppLogic.setMessage(result, "Record updated successfully."); return(RedirectToAction("Index")); } } else { result = clientLoginHelper.UpdateProfile(model, false); } if (result == 1) { model.Message = "Profile updated successfully!"; } else { model.Message = "Profile updation failed due to Session Expired!"; } } } catch (Exception ex) { new AppError().LogMe(ex); model.Message = "Profile Updation Failed"; return(View(model)); } return(Redirect(Url.Content("~/" + ClientSessionData.ClientPortalLink + "/settings/myprofile"))); } else { return(View(model)); } }
public ActionResult Index(ClientLogOnModel model) { try { string pwd = model.Password; if (ModelState.IsValidField("Email") && ModelState.IsValidField("Password")) { string message = string.Empty; int result = -1; DataTable dt = clientLoginHelper.AuthenticateClientUser(model, out result); if (result == 1) { string PortalUrl = clientLoginHelper.GetPortalUrlFromCurrentUrl(); ClientSessionData.ClientPortalLink = dt.Rows[0]["PortalLink"].ToString(); if (PortalUrl.ToLower() != ClientSessionData.ClientPortalLink.ToLower()) { TempData["CommonMessage"] = AppLogic.setFrontendMessage(1, "User Email does not belongs to this Portal Link"); } else { ClientSessionData.ClientUserName = model.Email; ClientSessionData.ClientName = dt.Rows[0]["Name"].ToString(); ClientSessionData.UserClientId = Convert.ToInt32(dt.Rows[0]["UserClientId"].ToString()); ClientSessionData.ClientCreatedOn = dt.Rows[0]["CreatedOn"].ToString(); ClientSessionData.ClientLastLoginOn = dt.Rows[0]["LastLogin"].ToString(); ClientSessionData.ClientRoleName = dt.Rows[0]["RoleName"].ToString(); model.IsProfileComplete = Convert.ToBoolean(dt.Rows[0]["IsProfileComplete"]); ClientSessionData.ClientStrataBoardId = Convert.ToInt32(dt.Rows[0]["StratasBoardId"]); ClientSessionData.ClientIsEmailNotification = Convert.ToBoolean(dt.Rows[0]["IsEmailNotification"]); ClientSessionData.ClientIsSMSNotification = Convert.ToBoolean(dt.Rows[0]["IsSMSNotification"]); ClientSessionData.ClientProfilePicture = dt.Rows[0]["ProfilePicture"].ToString(); ClientSessionData.ClientIsProfileCompleted = Convert.ToBoolean(dt.Rows[0]["IsProfileComplete"]); if (model.RememberMe) { HttpCookie cookie = new HttpCookie("ClientLogin"); cookie.Values.Add("LoginName", model.Email.Trim()); cookie.Values.Add("Password", pwd.Trim()); cookie.Values.Add("DtExp", DateTime.Now.AddDays(30).ToString()); cookie.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(cookie); } else { if (Request.Cookies["ClientLogin"] != null) { HttpCookie objCookie = Request.Cookies["ClientLogin"]; objCookie.Values.Add("DtExp", DateTime.Now.AddDays(-5).ToString()); objCookie.Expires = DateTime.Now.AddDays(-5); Response.Cookies.Add(objCookie); } } if (ClientSessionData.ClientRoleName.ToLower() == "owner") { if (!model.IsProfileComplete) { return(Redirect(Url.Content("~/" + ClientSessionData.ClientPortalLink + "/Logon/CompleteProfile"))); } else { return(Redirect(Url.Content("~/" + ClientSessionData.ClientPortalLink + "/dashboard/ownerdashboard"))); } } else { return(Redirect(Url.Content("~/" + ClientSessionData.ClientPortalLink + "/dashboard"))); } } } else if (result == 0) { TempData["CommonMessage"] = AppLogic.setFrontendMessage(2, "The user is Deactivated or Deleted by StrataFair Admin"); } else if (result == -2) { TempData["CommonMessage"] = AppLogic.setFrontendMessage(1, "Your password is invalid."); } else if (result == -3) { TempData["CommonMessage"] = AppLogic.setFrontendMessage(1, "Your Email Address is invalid."); } else { TempData["CommonMessage"] = AppLogic.setFrontendMessage(1, "Invalid Email Address or Password"); } } return(View(model)); } catch (Exception ex) { new AppError().LogMe(ex); TempData["CommonMessage"] = AppLogic.setFrontendMessage(1, "Invalid Username or Password"); return(View(model)); } }
public ActionResult CompleteProfile(ClientLogOnModel model, HttpPostedFileBase file) { model.ImageType = file; if (ClientSessionData.UserClientId != 0) { try { var imageTypes = new string[] { "image/png", "image/jpeg", "image/pjpeg" }; int _maxLength = MaxProfileImageLength * 1024 * 1024; ModelState.Remove("ImageType"); if (model.ImageType != null) { if (!imageTypes.Contains(model.ImageType.ContentType)) { ModelState.AddModelError("ImageType", "Please choose either a JPG or PNG image."); } else if (model.ImageType.ContentLength > _maxLength) { ModelState.AddModelError("ImageType", "Maximum allowed file size is " + MaxProfileImageLength + " MB."); } //else if (imageTypes.Contains(model.ImageType.ContentType) && model.ImageType.ContentLength <= _maxLength) //{ // System.Drawing.Image img = System.Drawing.Image.FromStream(model.ImageType.InputStream); // int height = img.Height; // int width = img.Width; // if (width > MaxProfileImageWidth || height > MaxProfileImageHeight) // { // ModelState.AddModelError("ImageType", "Maximum allowed file dimension is " + MaxProfileImageWidth + "*" + MaxProfileImageHeight); // } //} } ModelState.Remove("Email"); ModelState.Remove("Password"); int result = 0; if (ModelState.IsValid) { if (model.ImageType != null) { string ext = System.IO.Path.GetExtension(model.ImageType.FileName); model.ProfilePicture = Guid.NewGuid() + ext; string path = "~/Content/Resources/strataboard/" + ClientSessionData.ClientStrataBoardId + "/profileimages/"; if (!Directory.Exists(Server.MapPath(path))) { Directory.CreateDirectory(Server.MapPath(path)); } string Mappedpath = Server.MapPath(path + model.ProfilePicture); result = clientLoginHelper.CompleteProfile(model); if (result == 1) { // save the file locally model.ImageType.SaveAs(Mappedpath); // save the file on s3 int fileMapped = AwsS3Bucket.CreateFile("resources/strataboard/" + ClientSessionData.ClientStrataBoardId + "/profileimages/" + model.ProfilePicture, Mappedpath); // delete the file locally if (System.IO.File.Exists(Mappedpath)) { System.IO.File.Delete(Mappedpath); } string OldProfilePath = Server.MapPath(path + model.OldProfilePicture); if (System.IO.File.Exists(OldProfilePath)) { System.IO.File.Delete(OldProfilePath); } // delete the old file from s3 AwsS3Bucket.DeleteObject("resources/strataboard/" + ClientSessionData.ClientStrataBoardId + "/profileimages/" + model.OldProfilePicture); } } else { result = clientLoginHelper.CompleteProfile(model); } if (result == 1) { ClientSessionData.ClientIsProfileCompleted = true; return(Redirect(Url.Content("~/" + ClientSessionData.ClientPortalLink + "/dashboard"))); } else { TempData["CommonMessage"] = AppLogic.setFrontendMessage(2, "Profile Completion Failed."); return(View(model)); } } else { return(View(model)); } } catch (Exception ex) { new AppError().LogMe(ex); TempData["CommonMessage"] = AppLogic.setFrontendMessage(2, "Something wrong! Profile Completion Failed."); return(View(model)); } } else { return(View(model)); } }