public ActionResult CreateUser(LoanViewModel lvm) { GLobalClient cc = new GLobalClient(); if (lvm != null) { string value = lvm.AccountsModel.Email; string password = lvm.AccountsModel.pasword; string confirmpass = lvm.AccountsModel.confirmPassword; bool validatePass = ValidatePassword(password, confirmpass); var EncrypPassword = new CryptographyManager().ComputeHash(password, HashName.SHA256); password = EncrypPassword; lvm.AccountsModel.confirmPassword = password; lvm.AccountsModel.pasword = password; lvm.AccountsModel.Email = value; if (validatePass == false) { TempData["Message"] = "Password And Confirm Password Must Match"; } else if (validatePass == true) { bool val = DataReaders.Validate(value); if (val == true) { TempData["Message"] = "User Already Exist"; return(RedirectToAction("Signup", "index", new { area = "" })); } else if (val == false) { lvm.AccountsModel.Date = DateTime.Now; lvm.AccountsModel.DateTim = DateTime.Today; cc.CreateUser(lvm.AccountsModel); TempData["Message"] = "User Created Succesfully"; return(RedirectToAction("Signup", "index", new { area = "" })); } } } else { TempData["Message"] = "Error Creating User"; } return(RedirectToAction("Signup", "index", new { area = "" })); }
public ActionResult CreateUser(LoanViewModel lvm, FormCollection form) { GLobalClient cc = new GLobalClient(); try { if (lvm != null) { string value = lvm.AccountsModel.Email; string password = lvm.AccountsModel.pasword; string confirmpass = lvm.AccountsModel.confirmPassword; bool validatePass = ValidatePassword(password, confirmpass); var EncrypPassword = new CryptographyManager().ComputeHash(password, HashName.SHA256); password = EncrypPassword; lvm.AccountsModel.confirmPassword = password; lvm.AccountsModel.pasword = password; lvm.AccountsModel.Email = value; lvm.AccountsModel.Referal = Convert.ToString(form["Referal"]); if (validatePass == false) { TempData["Message"] = "Password And Confirm Password Must Match"; } else if (validatePass == true) { bool val = DataReaders.Validate(value); if (val == true) { TempData["Message"] = "User Already Exist"; // return RedirectToAction("Signup", "Home", new { area = "" }); ViewBag.channel = db.MarketingChannels; return(View("Signup")); } else if (val == false) { lvm.AccountsModel.Date = DateTime.Now; lvm.AccountsModel.DateTim = DateTime.Today; lvm.AccountsModel.isVissibles = 1; // This is For the Api // cc.CreateUser(lvm.AccountsModel); User users = new DataAccess.User(); users.confirmPassword = lvm.AccountsModel.confirmPassword; users.pasword = lvm.AccountsModel.pasword; users.Email = lvm.AccountsModel.Email; users.Date = lvm.AccountsModel.Date; users.DateTim = lvm.AccountsModel.DateTim; users.isVissibles = lvm.AccountsModel.isVissibles; users.firstname = lvm.AccountsModel.firstname; users.lastname = lvm.AccountsModel.lastname; users.Phone = lvm.AccountsModel.Phone; users.Referal = lvm.AccountsModel.Referal; //string lastid = "0"; //users.MyReferalCode = MyUtility.getReferralCode(lastid); users.ReferralLevel = MyUtility.getRefferalLevel(users.Referal); // users.MyReferalCode = int id = DataCreators.CreateUser(users); var channellist = Request["checkboxName"]; if (channellist != null) { string[] arr = channellist.Split(','); var chanList = removestring(arr); if (arr.Length > 0) { for (var i = 0; i < arr.Length; i++) { string arrc = Convert.ToString(arr[i]); insertMarketChannel(arrc, id); } } } if (id != 0) { string lastid = id.ToString(); users.MyReferalCode = MyUtility.getReferralCode(lastid); DataCreators.updatelastID(users); DataAccess.UserRole userroles = new DataAccess.UserRole(); userroles.UserId = id; userroles.RoleId = Convert.ToInt16(ConfigurationManager.AppSettings["DefaultUser"]); userroles.IsVissible = 1; userroles.dates = DateTime.Now; DataCreators.InsertUserRoles(userroles); TempData["Message"] = "User Created Succesfully"; //For LoggedIn User Session["id"] = lvm.AccountsModel.Email; Session["User"] = Session["id"]; var LoggedInuser = new LogginHelper(); user = LoggedInuser.LoggedInUser(); SendEmail(lvm); string Regpage = ConfigurationManager.AppSettings["DefaultRegister"]; return(Redirect(Regpage)); //return RedirectToAction("Index", "Dashboard"); // return RedirectToAction("Dashboard", "Dashboard"); } else { TempData["Message"] = "Registration Not Succesful Please Try Again!"; ViewBag.channel = db.MarketingChannels; } } } } else { TempData["Message"] = "Error Creating User"; ViewBag.channel = db.MarketingChannels; } return(RedirectToAction("Signup", "Home", new { area = "" })); } catch (Exception ex) { WebLog.Log(ex.Message.ToString()); return(null); } }