public ActionResult Login(Admin admin) { string encryptedPassword = BrokerUtility.EncryptURL(admin.Password); //DataSet dsUsers= BrokerWebDB.BrokerWebDB.validateAdminGetUsers(admin.Username, encryptedPassword); List <UserList> userList = new List <UserList>(); userList = BrokerWebDB.BrokerWebDB.validateAdminGetUsers(admin.Username, encryptedPassword); User adminInfo = BrokerWebDB.BrokerWebDB.getAdminInfo(admin.Username, encryptedPassword); if (userList != null) { if (userList.Count > 0) { Session["searchBy"] = "-1"; Session["UsersList"] = userList; Session["Error"] = "False"; Session["AdminId"] = adminInfo.UserId; Session["AdminUserName"] = adminInfo.EmailId; CreateLoginIdentity(adminInfo.EmailId, adminInfo.UserId); return(RedirectToAction("AdminHomePage", "Admin")); } else { ViewBag.error = "Invalid username and password"; } } else { ViewBag.error = "Invalid username and password"; } return(View()); }
public void CreateLoginIdentity(string Name, int UserId) { try { var identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, Name), new Claim(ClaimTypes.NameIdentifier, Convert.ToString(UserId)), }, DefaultAuthenticationTypes.ApplicationCookie, ClaimTypes.Name, ClaimTypes.Role); // if you want roles, just add as many as you want here (for loop maybe?) identity.AddClaim(new Claim(ClaimTypes.Role, "guest")); // tell OWIN the identity provider, optional // identity.AddClaim(new Claim(IdentityProvider, "Simplest Auth")); Authentication.SignIn(new AuthenticationProperties { IsPersistent = false }, identity); } catch (Exception ex) { BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "UpdateProfileView", ex.Message.ToString(), "HomeController.cs_UpdateProfileView()", BrokerUtility.GetIPAddress(Session["UserId"].ToString())); } }
public ActionResult ResetPassword(string EmailId, string Code) { try { string DecryptedEmailId = BrokerUtility.DecryptURL(EmailId); Session["EmailId"] = DecryptedEmailId; DataSet dsValidEmail = BrokerWSUtility.CheckForValidEmailId(DecryptedEmailId); if (dsValidEmail.Tables.Count > 0) { if (dsValidEmail.Tables[0].Rows.Count > 0) { if (dsValidEmail.Tables[0].Rows[0][0].ToString() != "0") { if (dsValidEmail.Tables[0].Rows[0]["ForgetPasswordRanNum"].ToString() != "") { if (dsValidEmail.Tables[0].Rows[0]["ForgetPasswordRanNum"].ToString() == Code) { Session["ResetPasswordUserType"] = dsValidEmail.Tables[0].Rows[0]["UserType"].ToString(); return(View()); } else { ViewBag.Message = "Password could not reset. Please try again"; return(View("ResetResult")); } } else { ViewBag.Message = "Reset password link expired."; return(View("ResetResult")); } } else { ViewBag.Message = "Password could not reset. Please try again"; return(View("ResetResult")); } } else { ViewBag.Message = "Password could not reset. Please try again"; return(View("ResetResult")); } } else { ViewBag.Message = "Password could not reset. Please try again"; return(View("ResetResult")); } } catch (Exception Ex) { ViewBag.Message = "Password could not reset. Please try again"; return(View("ResetResult")); } }
public JsonResult SendVideoEmail() { if (Session["UsersForVideoEmail"] != null) { try { DataSet ds = (DataSet)Session["UsersForVideoEmail"]; if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { bool flag = BrokerWSUtility.SendVideoLinkOnEmail(ds.Tables[0].Rows[i]["EmailId"].ToString(), ds.Tables[1].Rows[0]["Title"].ToString(), ds.Tables[1].Rows[0]["Url"].ToString(), ds.Tables[1].Rows[0]["Description"].ToString(), ds.Tables[0].Rows[i]["UserType"].ToString()); //For Testing //if (ds.Tables[0].Rows[i]["UserType"].ToString() == "Broker") //{ // bool flag = BrokerWSUtility.SendVideoLinkOnEmail(ds.Tables[0].Rows[i]["EmailId"].ToString(), ds.Tables[1].Rows[0]["Title"].ToString(), ds.Tables[1].Rows[0]["Url"].ToString(), ds.Tables[1].Rows[0]["Description"].ToString(), ds.Tables[0].Rows[i]["UserType"].ToString()); // break; //} } } } Session["UsersForVideoEmail"] = null; } catch (Exception Ex) { BrokerUtility.ErrorLog(0, "SendVideoEmail_WebSite", Ex.Message.ToString(), "BrokerBriefcaseController.cs_SendVideoEmail", ""); } } return(Json(new { result = "Success" }, JsonRequestBehavior.AllowGet)); }
public ActionResult VerifyEmailForApp(string EmailId, string RegistrationCode) { DataSet dsResult = null; DataSet dsValidEmail = null; try { string DecryptEmail = BrokerUtility.DecryptURL(EmailId); dsValidEmail = BrokerWSUtility.CheckForValidEmailId(DecryptEmail); if (Convert.ToBoolean(dsValidEmail.Tables[0].Rows[0]["IsEmailIdVerified"].ToString()) == false) { dsResult = BrokerWSUtility.VerifyUserDetails(DecryptEmail, RegistrationCode); if (dsResult.Tables.Count > 0) { ViewData["EmailVerifyMessage"] = strEmailVerifyMessage; if (dsResult.Tables[0].Rows[0]["UserType"].ToString() == "Customer") { //ViewData["LoginUrl"] = "CustomerLogin"; ViewData["Login"] = "******"; } else { //ViewData["LoginUrl"] = "BrokerLogin"; ViewData["Login"] = "******"; } return(View()); } else { ViewData["EmailVerifyMessage"] = "Email Verification Failed. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } } else { ViewData["EmailVerifyMessage"] = "Your email address is already verified."; if (dsValidEmail.Tables[0].Rows[0]["IsEmailIdVerified"].ToString() == "Customer") { ViewData["Login"] = "******"; } else { ViewData["Login"] = "******"; } return(View("VerifyEmailFail")); } } catch (Exception Ex) { ViewData["EmailVerifyMessage"] = "Email Verification Failed. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } }
public ActionResult ResetPassword(ResetPassword Info) { try { if (ModelState.IsValid) { string Password = "", TempPass = ""; if (Info.Password != "" && Info.Password != null) { Password = Info.Password.ToString(); TempPass = BrokerUtility.EncryptURL(Password); int Flag = BrokerUtility.ResetPassWord(Session["EmailId"].ToString(), TempPass); if (Flag > 0) { int Flag1 = BrokerWSUtility.ForgetPasswordRanNum(Session["EmailId"].ToString(), ""); string UserType = Session["ResetPasswordUserType"].ToString(); if (UserType == "Customer") { ViewBag.LoginUrl = "CustomerLogin"; } else if (UserType == "Broker") { ViewBag.LoginUrl = "BrokerLogin"; } ViewBag.Message = "Your password has been reset successfully."; return(View("ResetResult")); } else { ViewBag.Message = "Password could not reset. Please try again. "; return(View("ResetResult")); } } else { return(View()); } } else { return(View()); } } catch (Exception Ex) { ViewBag.Message = "Password could not reset. Please try again. "; return(View("ResetResult")); } }
public JsonResult IsEmailIdAlreadyExist(MeinekeCustomerSignUp Cust) { DataSet dsCheckUserExist = BrokerUtility.CheckUSerExist(Cust.EmailId.ToString()); if (dsCheckUserExist.Tables.Count > 0) { return(Json("Email Id already registered.", JsonRequestBehavior.AllowGet)); } else { return(Json(true, JsonRequestBehavior.AllowGet)); } }
public ActionResult SystemError() { try { Authentication.SignOut(DefaultAuthenticationTypes.ApplicationCookie); //var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (Session["UserId"] != null) { Session["UserId"] = null; } if (Session["EmailId"] != null) { Session["EmailId"] = null; } if (Session["FirstName"] != null) { Session["FirstName"] = null; } if (Session["LastName"] != null) { Session["LastName"] = null; } if (Session["ZipCode"] != null) { Session["ZipCode"] = null; } if (Session["LinkedInLogInBy"] != null) { Session["LinkedInLogInBy"] = null; } if (Session["FacebookLogInBy"] != null) { Session["FacebookLogInBy"] = null; } } catch (Exception ex) { BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "CreateLoginIdentity", ex.Message.ToString(), "LoginController.cs_CreateLoginIdentity()", BrokerUtility.GetIPAddress(Session["UserId"].ToString())); } return(RedirectToAction("Index", "Home")); }
public ActionResult UpdateProfileView() { UpdateModel UpdateModel = new UpdateModel(); List <spGetUserDetails_Result> oUserDetails = null; if (Session["UserId"] != null) { int iUserId = Convert.ToInt32(Session["UserId"]); oUserDetails = BrokerUtility.GetUserDetails(iUserId); UpdateModel.FirstName = oUserDetails[0].FirstName; UpdateModel.LastName = oUserDetails[0].LastName; } return(View(UpdateModel)); }
public ActionResult CustomerChat(string BrokerMessageId, string CustomerMessageId, string BrokerId, string CustomerId, string CustomerName) { DataSet dsMainMsgDetails = null; string MainMessage = "", IsRead = "", LocalDateTime = ""; string this_BrokerMessageId = BrokerMessageId; string this_CustomerMessageId = CustomerMessageId; string this_BrokerId = BrokerId; string this_CustomerId = CustomerId; string this_CustomerName = CustomerName; this_BrokerMessageId = BrokerUtility.DecryptURL(this_BrokerMessageId); this_CustomerMessageId = BrokerUtility.DecryptURL(this_CustomerMessageId); this_BrokerId = BrokerUtility.DecryptURL(this_BrokerId); this_CustomerId = BrokerUtility.DecryptURL(this_CustomerId); this_CustomerName = BrokerUtility.DecryptURL(this_CustomerName); ViewBag.BrokerMessageId = this_BrokerMessageId; ViewBag.CustomerMessageId = this_CustomerMessageId; ViewBag.BrokerId = this_BrokerId; ViewBag.CustomerId = this_CustomerId; ViewBag.BrokerName = this_CustomerName; ViewBag.FirstName = Session["FirstName"].ToString(); ViewBag.LastName = Session["LastName"].ToString(); dsMainMsgDetails = BrokerWebDB.BrokerWebDB.GetMainMessage(this_BrokerId, this_CustomerId, this_BrokerMessageId, this_CustomerMessageId, "CustomerMessages"); if (dsMainMsgDetails.Tables.Count > 0) { if (dsMainMsgDetails.Tables[0].Rows.Count > 0) { MainMessage = dsMainMsgDetails.Tables[0].Rows[0][0].ToString(); IsRead = dsMainMsgDetails.Tables[0].Rows[0]["IsRead"].ToString(); LocalDateTime = dsMainMsgDetails.Tables[0].Rows[0]["LocalDateTime"].ToString(); } } ViewBag.MainMessage = MainMessage; ViewBag.IsRead = IsRead; ViewBag.LocalDateTime = LocalDateTime; if (Session["WebServiceURL"] != null) { ViewBag.WebServiceURL = Session["WebServiceURL"].ToString(); } return(View()); }
public ActionResult VerifyEmail(ResetPassword Info) { try { if (ModelState.IsValid) { string Password = "", TempPass = ""; if (Info.Password != "" && Info.Password != null) { Password = Info.Password.ToString(); TempPass = BrokerUtility.EncryptURL(Password); int Flag = BrokerWSUtility.CreateNewPassword(Session["DecryptedEmailId"].ToString(), TempPass); if (Flag > 0) { ViewData["EmailVerifyMessage"] = strEmailVerifyMessage; ViewData["LoginUrl"] = "CustomerLogin"; return(View("VerifyEmailSuccess")); } else { ViewData["EmailVerifyMessage"] = "Email verification link is expired. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } } else { return(View()); } } else { return(View()); } } catch (Exception Ex) { ViewData["EmailVerifyMessage"] = "Email Verification Failed. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } //return View("Index"); }
public JsonResult EncryptBrokerData(string BrokerMessageId, string CustomerMessageId, string BrokerId, string CustomerId, string CustomerName) { string this_BrokerMessageId = BrokerMessageId; string this_CustomerMessageId = CustomerMessageId; string this_BrokerId = BrokerId; string this_CustomerId = CustomerId; string this_CustomerName = CustomerName; this_BrokerMessageId = BrokerUtility.EncryptURL(this_BrokerMessageId); this_CustomerMessageId = BrokerUtility.EncryptURL(this_CustomerMessageId); this_BrokerId = BrokerUtility.EncryptURL(this_BrokerId); this_CustomerId = BrokerUtility.EncryptURL(this_CustomerId); this_CustomerName = BrokerUtility.EncryptURL(this_CustomerName); return(Json(new { BrokerMessageId = this_BrokerMessageId, CustomerMessageId = this_CustomerMessageId, BrokerId = this_BrokerId, CustomerId = this_CustomerId, CustomerName = this_CustomerName }, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateProfileView(UpdateModel data, FormCollection val) { int user; try { if (ModelState.IsValid) { string encryptedPassword = BrokerUtility.EncryptURL(data.Password); int? state = data.StateId; int? country = data.CountryId; user = BrokerUtility.UpdateUser(Session["UserId"].ToString(), encryptedPassword, data.Address, data.City, state, country, data.PinCode, data.MobNo, "1", data.UserType, "1"); if (user > 0) { CreateLoginIdentity(data.FirstName + ' ' + data.LastName, Convert.ToInt32(Session["UserId"].ToString())); return(RedirectToAction("Index", "Home")); } else { ViewBag.UserExist = "Error occured while updating your profile."; } } else { ViewBag.validateerror = "Please validate all input"; } } catch (Exception ex) { BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "UpdateProfileView", ex.Message.ToString(), "HomeController.cs_UpdateProfileView()", BrokerUtility.GetIPAddress(Session["UserId"].ToString())); } return(View(data)); //return View(model); }
public ActionResult VerifyEmail(string EmailId, string RegistrationCode) { try { DataSet dsResult = null; string DecryptEmail = BrokerUtility.DecryptURL(EmailId); Session["DecryptedEmailId"] = DecryptEmail; DataSet dsValidEmail = BrokerWSUtility.CheckForValidEmailId(DecryptEmail); //Check for Customer Email verification if (Convert.ToBoolean(dsValidEmail.Tables[0].Rows[0]["IsEmailIdVerified"].ToString()) == false && dsValidEmail.Tables[0].Rows[0]["UserType"].ToString() == "Customer") { DataSet ds = new DataSet(); ds = BrokerWebDB.BrokerWebDB.CheckForValidUserDetails(Session["DecryptedEmailId"].ToString(), RegistrationCode); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { return(View()); } else { ViewData["EmailVerifyMessage"] = "Email verification link is expired. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } } else { ViewData["EmailVerifyMessage"] = "Email verification link is expired. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } } //Check for Broker Email verification else if (Convert.ToBoolean(dsValidEmail.Tables[0].Rows[0]["IsEmailIdVerified"].ToString()) == false && dsValidEmail.Tables[0].Rows[0]["UserType"].ToString() == "Broker") { dsResult = BrokerWSUtility.VerifyUserDetails(DecryptEmail, RegistrationCode); if (dsResult.Tables.Count > 0) { ViewData["EmailVerifyMessage"] = strEmailVerifyMessage; ViewData["LoginUrl"] = "BrokerLogin"; return(View("VerifyEmailSuccess")); } else { ViewData["EmailVerifyMessage"] = "Email verification link is expired. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } } //If both Customer and Broker are already verified. else { ViewData["EmailVerifyMessage"] = "Your email address is already verified."; if (dsValidEmail.Tables[0].Rows[0]["UserType"].ToString() == "Customer") { ViewData["Login"] = "******"; } else { ViewData["Login"] = "******"; } return(View("VerifyEmailFail")); } } catch (Exception Ex) { ViewData["EmailVerifyMessage"] = "Email Verification Failed. Please try again"; ViewData["Login"] = ""; return(View("VerifyEmailFail")); } }
public ActionResult Index(CustomerRegistration Cust, IEnumerable <HttpPostedFileBase> file) { if (ModelState.IsValid) { try { if (Request.Form["Submit"] != null) { string FirstName = "", LastName = "", Email = "", Phone1 = "", Phone2 = "", Phone3 = "", Password = "", TempPass = "", ZipCode = "", ProfilePhoto = "", HouseType = "", Address = "", IsCars = "", Occupation = "", CompanyName = "", Phone = "", FieldName1 = "", RenamedImageName = "", FileName2 = ""; int NoOfCars = 0, UserId; //bool IsHavingCars = false; List <spUpdateCustomerForWeb_Result> CustDetails = null; UserId = Convert.ToInt32(Session["UserId"].ToString()); if (Cust.FirstName != null) { FirstName = Cust.FirstName.ToString(); Session["FirstName"] = FirstName; } if (Cust.LastName != null) { LastName = Cust.LastName.ToString(); Session["LastName"] = LastName; } if (Cust.PhoneNo1 != null) { Phone1 = Cust.PhoneNo1.ToString(); } Phone = Phone1;//Change 29Dec16 if (Cust.ZipCode != null) { ZipCode = Cust.ZipCode.ToString(); } if (Cust.HouseType != null) { HouseType = Cust.HouseType.ToString(); } if (Cust.Address != null) { Address = Cust.Address.ToString(); } if (Cust.IsCars != null) { IsCars = Cust.IsCars.ToString(); } if (Cust.NumberofCars != null) { if (IsCars == "Yes") { NoOfCars = Convert.ToInt32(Cust.NumberofCars.ToString()); } else { NoOfCars = 0; } } if (Cust.Occupation != null) { if (Cust.Occupation.ToString() == "Business Owner") { Occupation = "Self Employed"; } else { Occupation = Cust.Occupation.ToString(); } } if (Cust.CompanyName != null) { CompanyName = Cust.CompanyName.ToString(); } //Save Details of Profile Picture if (Cust.IsProfilePhotoChanged == "Yes") { if (file == null) { } else { foreach (var f in file) { if (f != null) { if (f.ContentLength > 0) { int MaxContentLength = 1024 * 1024 * 4; //Size = 4 MB string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf", ".jpe", ".jpeg" }; if (!AllowedFileExtensions.Contains (f.FileName.Substring(f.FileName.LastIndexOf('.')).ToLower())) { ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions)); } else if (f.ContentLength > MaxContentLength) { ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB"); } else { var fileName = Path.GetFileName(f.FileName); //var Name = Path.GetFileNameWithoutExtension(f.FileName); var path = Path.Combine(Server.MapPath("~/UploadedDoc"), fileName); //Save file on server. //f.SaveAs(path); //Convert input file to Base 64 string byte[] binaryData; binaryData = new Byte[f.InputStream.Length]; long bytesRead = f.InputStream.Read(binaryData, 0, (int)f.InputStream.Length); f.InputStream.Close(); string base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); string FileName1 = ""; string FieldName = ""; string ProfilePicFile = ""; string ProfilePic = Cust.ProfilePhoto.ToString().Replace("C:\\fakepath\\", ""); if (ProfilePic == fileName) { FileName1 = System.Web.HttpContext.Current.Server.MapPath("~/ProfilePicture/" + Cust.Email.ToString() + "_" + UserId + ".txt"); FieldName = "ProfilePicture"; FileName2 = Cust.Email.ToString() + "_" + UserId + ".txt"; ProfilePicFile = System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Cust.Email.ToString() + "_" + UserId + ".png"); bool CheckFile1 = BrokerUtility.CheckFile(ProfilePicFile); byte[] imageBytes1 = Convert.FromBase64String(base64String); //MemoryStream ms1 = new MemoryStream(imageBytes1, 0, imageBytes1.Length); MemoryStream ms1 = new MemoryStream(binaryData, 0, binaryData.Length); //ms1.Write(imageBytes1, 0, imageBytes1.Length); ms1.Write(binaryData, 0, binaryData.Length); System.Drawing.Image image1 = System.Drawing.Image.FromStream(ms1, true); //image1.Save(System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Cust.Email.ToString() + "_" + UserId + ".png"), System.Drawing.Imaging.ImageFormat.Png); System.Drawing.Image thumbnail = image1.GetThumbnailImage(200, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); thumbnail.Save(System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Cust.Email.ToString() + "_" + UserId + ".png"), System.Drawing.Imaging.ImageFormat.Png); FieldName1 = "ProfilePictureImg"; RenamedImageName = Cust.Email.ToString() + "_" + UserId + ".png"; //Check for the file already exist or not bool CheckFile = BrokerUtility.CheckFile(FileName1); if (CheckFile) { //Create a text file of Base 64 string bool result = BrokerUtility.WriteFile(FileName1, base64String); } } } } } } } } else { } //Save the Details of Customer CustDetails = BrokerWebDB.BrokerWebDB.SaveCustomerProfileDetails(FirstName, LastName, Phone, Address, ZipCode, HouseType, IsCars, NoOfCars, Occupation, CompanyName, FileName2, RenamedImageName, Cust.IsProfilePhotoChanged, UserId, "", "", ""); if (CustDetails.Count > 0) { //TempData["CustDetails"] = Cust; return(RedirectToAction("CustomerProfile", "Profile")); } else { return(View()); } //BrokerUtility.SaveCustomerBasicDetails(FirstName, LastName, Phone, Email, Address, ZipCode, TempPass, Encryptrandom, HouseType, IsCars, NoOfCars, Occupation, CompanyName); } else if (Request.Form["Cancel"] != null) { //TempData["CustDetails"] = Cust; return(RedirectToAction("CustomerProfile", "Profile")); //return View("","") } } catch (Exception Ex) { BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "Index_POST_Wesite", Ex.Message.ToString(), "CustomerRegistrationController.cs_Index_POST", BrokerUtility.GetIPAddress(Session["UserId"].ToString())); return(View()); } return(View()); } else { return(View()); } }
public ActionResult APSPCustomerSignUp(MeinekeCustomerSignUp Cust, IEnumerable <HttpPostedFileBase> file) { if (ModelState.IsValid) { try { string FirstName = "", LastName = "", Email = "", Phone1 = "", Phone2 = "", Phone3 = "", Password = "", TempPass = "", ZipCode = "", ProfilePhoto = "", HouseType = "", Address = "", IsCars = "", Occupation = "", CompanyName = "", Phone = "", FieldName1 = "", RenamedImageName = "", FileName2 = "", NoofEmployee = "", EstPremium = "", Website = ""; int NoOfCars = 0, UserId = 0; List <uspSaveCustomerBasicDetails_Result> User1 = null; //UserId = Convert.ToInt32(Session["UserId"].ToString()); if (Cust.FirstName != null) { FirstName = Cust.FirstName.ToString(); } if (Cust.LastName != null) { LastName = Cust.LastName.ToString(); } if (Cust.CompanyName != null) { CompanyName = Cust.CompanyName.ToString(); } if (Cust.Address != null) { Address = Cust.Address.ToString(); } if (Cust.EmailId != null) { Email = Cust.EmailId.ToString(); } if (Cust.PhoneNo != null) { Phone = Cust.PhoneNo.ToString(); } if (Cust.Website != null) { Website = Cust.Website.ToString(); } if (Cust.ZipCode != null) { ZipCode = Cust.ZipCode.ToString(); } if (Cust.NoofEmployees != null) { NoofEmployee = Cust.NoofEmployees.ToString(); } if (Cust.EstPremium != null) { EstPremium = Cust.EstPremium.ToString(); } string random = BrokerWSUtility.GetRandomNumber(); string Encryptrandom = BrokerUtility.EncryptURL(random); Session["random"] = Encryptrandom; User1 = BrokerUtility.SaveCustomerBasicDetails(FirstName, LastName, Phone, Email, Address, ZipCode, TempPass, Encryptrandom, HouseType, IsCars, NoOfCars, Occupation, CompanyName, NoofEmployee, EstPremium, Website, "APSP"); int Flag = 0; if (User1.Count > 0) { UserId = Convert.ToInt32(User1[0].UserId.ToString()); Session["UserId"] = UserId; Session["EmailId"] = User1[0].EmailId.ToString(); //////////////////// Access Profile Pic and Resume Files ////////////////////////// if (file == null) { } else { foreach (var f in file) { if (f != null) { if (f.ContentLength > 0) { int MaxContentLength = 1024 * 1024 * 4; //Size = 4 MB string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf", ".jpe", ".jpeg" }; if (!AllowedFileExtensions.Contains (f.FileName.Substring(f.FileName.LastIndexOf('.')).ToLower())) { ModelState.AddModelError("File", "Please file of type: " + string.Join(", ", AllowedFileExtensions)); } else if (f.ContentLength > MaxContentLength) { ModelState.AddModelError("File", "Your file is too large, maximum allowed size is: " + MaxContentLength + " MB"); } else { var fileName = Path.GetFileName(f.FileName); //var Name = Path.GetFileNameWithoutExtension(f.FileName); var path = Path.Combine(Server.MapPath("~/UploadedDoc"), fileName); //Save file on server. //f.SaveAs(path); //Convert input file to Base 64 string byte[] binaryData; binaryData = new Byte[f.InputStream.Length]; long bytesRead = f.InputStream.Read(binaryData, 0, (int)f.InputStream.Length); f.InputStream.Close(); string base64String = System.Convert.ToBase64String(binaryData, 0, binaryData.Length); string FileName1 = ""; // string FileName2 = ""; string FieldName = ""; string ProfilePic = Cust.ProfilePicture.ToString().Replace("C:\\fakepath\\", ""); if (ProfilePic == fileName) { FileName1 = System.Web.HttpContext.Current.Server.MapPath("~/ProfilePicture/" + Cust.EmailId.ToString() + "_" + UserId + ".txt"); FieldName = "ProfilePicture"; FileName2 = Cust.EmailId.ToString() + "_" + UserId + ".txt"; //Save Image on Server also. // Convert byte[] to Image byte[] imageBytes1 = Convert.FromBase64String(base64String); MemoryStream ms1 = new MemoryStream(imageBytes1, 0, imageBytes1.Length); ms1.Write(imageBytes1, 0, imageBytes1.Length); System.Drawing.Image image1 = System.Drawing.Image.FromStream(ms1, true); //image1.Save(System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Email + "_" + UserId + ".png"), System.Drawing.Imaging.ImageFormat.Png); System.Drawing.Image thumbnail = image1.GetThumbnailImage(200, 200, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero); thumbnail.Save(System.Web.HttpContext.Current.Server.MapPath("~/UploadedImages/ProfilePicture/" + Email + "_" + UserId + ".png"), System.Drawing.Imaging.ImageFormat.Png); FieldName1 = "ProfilePictureImg"; RenamedImageName = Cust.EmailId.ToString() + "_" + UserId + ".png"; } //Check for the file already exist or not bool CheckFile = BrokerUtility.CheckFile(FileName1); if (CheckFile) { //Create a text file of Base 64 string bool result = BrokerUtility.WriteFile(FileName1, base64String); if (result) { Flag = BrokerUtility.SaveBrokerFiles(FileName2, UserId, FieldName, FieldName1, RenamedImageName); } } } } } } } // Send Verification Link on Email Id //string random = BrokerWSUtility.GetRandomNumber(); bool EmailFlag = false; EmailFlag = BrokerWSUtility.SendRegistrationEmailFromWebSite(Session["EmailId"].ToString(), Session["random"].ToString(), Session["UserId"].ToString(), "Customer"); //EmailFlag = true; if (EmailFlag) { ViewBag.VerificationMessage = "You are registered successfully but yet not activated. "; ViewBag.VerificationMessage1 = "Please accept your verification email."; ViewBag.Company = "APSP"; return(View("CustomerSuccess")); } else { //If User registerd successfully, but verification link has not //been sent over EmailId //ViewBag.VerificationMessage = "You are registered successfully but yet not activated. <br/>Please accept your verification email."; ViewBag.Company = "APSP"; return(View("CustomerError")); } } } catch (Exception Ex) { BrokerUtility.ErrorLog(Convert.ToInt32(Session["UserId"].ToString()), "Index_POST_Wesite", Ex.Message.ToString(), "CustomerRegistrationController.cs_Index_POST", BrokerUtility.GetIPAddress(Session["UserId"].ToString())); return(View()); } return(View()); } return(View()); }
public ActionResult Index(BrokkrrBriefcase obj_briefcase, string[] chkCompany) { if (obj_briefcase.Actionsname == "Submit") { #region Save Video Details try { //if (ModelState.IsValid) //{ SqlDateTime?sqldatenull = null; int uploadedby = 0; string userid = "", url = "", title = "", description = "", assignedcompany = "", fromdate = "", todate = ""; string[] strURL; bool isdeleted = false; ViewBag.UserId = Session["UserId"].ToString(); ViewBag.User = "******"; userid = ViewBag.UserId; if (userid != "") { if (obj_briefcase.Url != "") { url = obj_briefcase.Url; if (!(url.Contains("https://youtube.com/embed")) && !(url.Contains("https://www.youtube.com/embed"))) { strURL = url.Split('/'); if (strURL[3] != "") { url = "https://youtube.com/embed/" + strURL[3]; } } else { } } else { url = ""; } if (obj_briefcase.Title != "") { title = obj_briefcase.Title; } else { title = ""; } if (obj_briefcase.Description != "" && obj_briefcase.Description != null) { description = obj_briefcase.Description; Regex regex = new Regex(@"(\r\n|\r|\n)+"); description = regex.Replace(description, "<br />"); } else { description = ""; } if (chkCompany != null) { foreach (var Comp in chkCompany) { assignedcompany = assignedcompany + "," + Comp; } assignedcompany = assignedcompany.TrimStart(','); } if (obj_briefcase.DateFrom != null && obj_briefcase.DateFrom != Convert.ToDateTime("1/1/0001 12:00:00 AM")) { fromdate = Convert.ToDateTime(obj_briefcase.DateFrom).ToShortDateString(); } else { fromdate = null; } if (obj_briefcase.DateTo != null && obj_briefcase.DateTo != Convert.ToDateTime("1/1/0001 12:00:00 AM")) { todate = Convert.ToDateTime(obj_briefcase.DateTo).ToShortDateString(); } else { todate = null; } if (obj_briefcase.UploadedBy != null) { uploadedby = Convert.ToInt32(userid); } } int val = 0; val = BrokerWebDB.BrokerWebDB.saveVideoDetails(url, title, description, assignedcompany, fromdate, todate, uploadedby); if (val > 0) { if (assignedcompany != "") { /*Insert data into table WatchedVideoHistory for selected company users and all brokers*/ BrokerWebDB.BrokerWebDB.SaveUserListInWatchedVideoHistory(assignedcompany, val); DataSet ds = new DataSet(); ds = BrokerWebDB.BrokerWebDB.GetUserListForVideoNotification(assignedcompany); if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string DeviceId = "", NewDevice = "", message = "", UId = ""; DeviceId = ds.Tables[0].Rows[i]["DeviceId"].ToString(); UId = ds.Tables[0].Rows[i]["UserId"].ToString(); //BrokerUtility.ErrorLog(0, "1Index", "" + DeviceId + "," + UId, "BrokerBriefcaseController.cs_Index", ""); int AdnroidDevice = DeviceId.IndexOf("Android"); int IosDevice = DeviceId.IndexOf("iOS"); if (AdnroidDevice >= 0) { NewDevice = DeviceId.Replace("Android", ""); message = "New video - " + title + " added in your brokkrr briefcase"; BrokerUtility.DoPushNotification(NewDevice, message, "", "1", UId); } else if (IosDevice >= 0) { NewDevice = DeviceId.Replace("iOS", ""); message = "New video - " + title + " added in your brokkrr briefcase"; BrokerUtility.DoPushNotificationForiOS(NewDevice, message, "", "1", UId); } } } } DataSet dsUsers = new DataSet(); dsUsers = BrokerWebDB.BrokerWebDB.GetUserListForVideoEmail(assignedcompany, "Submit", 0); DataTable dt = new DataTable(); dt.Columns.Add("Title"); dt.Columns.Add("Description"); dt.Columns.Add("Url"); //dt.Columns.Add("Description"); dt.Rows.Add(title, description, url); dsUsers.Tables.Add(dt); dsUsers.AcceptChanges(); Session["UsersForVideoEmail"] = dsUsers; } } return(RedirectToAction("Index", "BrokkrrBriefcase")); //} //return RedirectToAction("Index", "BrokkrrBriefcase"); } catch (Exception ex) { throw ex; } #endregion Save Video Details } if (obj_briefcase.Actionsname == "Update") { #region Update Video Details try { BrokerDBEntities Db = new BrokerDBEntities(); //if (ModelState.IsValid) //{ SqlDateTime?sqldatenull = null; int uploadedby = 0; int Id = 0; string userid = "", url = "", title = "", description = "", assignedcompany = "", fromdate = "", todate = "", createdate = "", alreadyassignedcomp = ""; bool isdeleted = false; ViewBag.UserId = Session["UserId"].ToString(); ViewBag.User = "******"; userid = ViewBag.UserId; if (userid != "") { if (obj_briefcase.Id.ToString() != "") { Id = obj_briefcase.Id; } if (obj_briefcase.Url != "") { url = obj_briefcase.Url; } else { url = ""; } if (obj_briefcase.Title != "") { title = obj_briefcase.Title; } else { title = ""; } if (obj_briefcase.Description != "" && obj_briefcase.Description != null) { description = obj_briefcase.Description; Regex regex = new Regex(@"(\r\n|\r|\n)+"); description = regex.Replace(description, "<br />"); } else { description = ""; } if (chkCompany != null) { foreach (var Comp in chkCompany) { assignedcompany = assignedcompany + "," + Comp; } assignedcompany = assignedcompany.TrimStart(','); } if (obj_briefcase.DateFrom != null && obj_briefcase.DateFrom != Convert.ToDateTime("1/1/0001 12:00:00 AM")) { fromdate = Convert.ToDateTime(obj_briefcase.DateFrom).ToShortDateString(); } else { fromdate = null; } if (obj_briefcase.DateTo != null && obj_briefcase.DateTo != Convert.ToDateTime("1/1/0001 12:00:00 AM")) { todate = Convert.ToDateTime(obj_briefcase.DateTo).ToShortDateString(); } else { todate = null; } if (obj_briefcase.UploadedBy != null) { uploadedby = Convert.ToInt32(userid); } } int val = 0; var resultData = from data in Db.BrokerBriefcases where data.Id == Id select new { data.AssignedCompany }; foreach (var d in resultData) { alreadyassignedcomp = d.AssignedCompany; } val = BrokerWebDB.BrokerWebDB.UpdateVideoDetails(Id, url, title, description, assignedcompany, fromdate, todate, uploadedby); if (val > 0) { string[] strsplit, strsplitAlreadyAssigned; int round = 0; if (assignedcompany != "") { /*Insert data into table WatchedVideoHistory for selected company users and all brokers*/ BrokerWebDB.BrokerWebDB.SaveUserListInWatchedVideoHistory(assignedcompany, Id); if (alreadyassignedcomp != assignedcompany) { strsplit = assignedcompany.Split(','); if (strsplit.Length > 0) { for (int j = 0; j < strsplit.Length; j++) { if (!(alreadyassignedcomp.Contains(strsplit[j]))) { string s = strsplit[j]; DataSet ds = new DataSet(); ds = BrokerWebDB.BrokerWebDB.GetUserListForVideoNotification(s); //if (round > 0) //{ for (int k = 0; k < ds.Tables[0].Rows.Count; k++) { DataRow dr = ds.Tables[0].Rows[k]; string s1 = dr["UserType"].ToString(); if (dr["UserType"].ToString() == "Broker") { dr.Delete(); ds.AcceptChanges(); k--; } } //} if (ds.Tables.Count > 0) { if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { string DeviceId = "", NewDevice = "", message = "", UId = ""; DeviceId = ds.Tables[0].Rows[i]["DeviceId"].ToString(); UId = ds.Tables[0].Rows[i]["UserId"].ToString(); int AdnroidDevice = DeviceId.IndexOf("Android"); int IosDevice = DeviceId.IndexOf("iOS"); if (AdnroidDevice >= 0) { NewDevice = DeviceId.Replace("Android", ""); message = "New video - " + title + " added in your brokkrr briefcase"; BrokerUtility.DoPushNotification(NewDevice, message, "", "1", UId); } else if (IosDevice >= 0) { NewDevice = DeviceId.Replace("iOS", ""); message = "New video - " + title + " added in your brokkrr briefcase"; BrokerUtility.DoPushNotificationForiOS(NewDevice, message, "", "1", UId); } } } } DataSet dsUsers = new DataSet(); dsUsers = BrokerWebDB.BrokerWebDB.GetUserListForVideoEmail(s, "Update", Id); DataTable dt = new DataTable(); dt.Columns.Add("Title"); dt.Columns.Add("Description"); dt.Columns.Add("Url"); //dt.Columns.Add("Description"); dt.Rows.Add(title, description, url); dsUsers.Tables.Add(dt); dsUsers.AcceptChanges(); Session["UsersForVideoEmail"] = dsUsers; //round++; } else { } } } } } } return(RedirectToAction("Index", "BrokkrrBriefcase")); //} //return RedirectToAction("Index", "BrokkrrBriefcase"); } catch (Exception ex) { throw ex; } #endregion Update Video Details } return(RedirectToAction("Index", "BrokkrrBriefcase")); }
public ActionResult Index() { CustomerRegistration Data = new CustomerRegistration(); List <spCheckUserExist_Result> oUserDetsils = null; try { if (Session["EmailId"].ToString() != "") { oUserDetsils = BrokerWebDB.BrokerWebDB.GetCustomerDetails(Session["EmailId"].ToString(), Session["UserId"].ToString()); if (oUserDetsils != null) { Data.FirstName = oUserDetsils[0].FirstName; Data.LastName = oUserDetsils[0].LastName; Data.Email = oUserDetsils[0].EmailId; Data.PhoneNo1 = oUserDetsils[0].PhoneNo; Data.HouseType = oUserDetsils[0].HouseType; Data.Address = oUserDetsils[0].AddressofHouse; Data.ZipCode = oUserDetsils[0].PinCode; Data.CompanyName = oUserDetsils[0].CompanyName; if (oUserDetsils[0].TypeOfEmployment != "" || oUserDetsils[0].TypeOfEmployment != null) { if (oUserDetsils[0].TypeOfEmployment == "Self Employed") { Data.Occupation = "Business Owner"; } else { Data.Occupation = oUserDetsils[0].TypeOfEmployment; } } Data.IsProfilePhotoChanged = "No"; if (oUserDetsils[0].IsHavingCar == true) { Data.IsCars = "Yes"; Data.NumberofCars = oUserDetsils[0].NoOfCars.ToString(); } else { Data.IsCars = "No"; Data.NumberofCars = "0"; } if (oUserDetsils[0].ProfilePicture != "" && oUserDetsils[0].ProfilePicture != null) { Data.ProfilePhoto = oUserDetsils[0].FirstName + "_" + oUserDetsils[0].LastName + ".Png"; } } } } catch (Exception Ex) { BrokerUtility.ErrorLog(0, "Index_GET_Website", Ex.Message.ToString(), "CustomerRegistrationController.cs_Index_GET()", ""); } return(View(Data)); }