public ActionResult Register(RegistrationPageModel model) { if (model is null) { throw new ArgumentNullException(nameof(model)); } System.Threading.Thread.Sleep(1000); if (!this.ModelState.IsValid) { return(this.View(model)); } if (this.UserRepository.GetByLogin(model.Login) != null) { this.ModelState.AddModelError(string.Empty, "Username is already taken"); return(this.View(model)); } if (!this.ConfigurationService.GetBool(ConfigurationNames.ALLOW_DUPLICATE_EMAIL) && this.UserRepository.GetByEmail(model.Email) != null) { this.ModelState.AddModelError(string.Empty, "Email is already taken"); return(this.View(model)); } bool EmailValidationRequired = this.ConfigurationService.GetBool(ConfigurationNames.REQUIRE_EMAIL_VALIDATION); User newUser; using (IWriteContext context = this.UserRepository.WriteContext()) { newUser = new User() { Login = model.Login, Password = model.Password, Email = model.Email }; this.UserRepository.AddOrUpdate(newUser); if (EmailValidationRequired) { this.EmailValidationRepository.GenerateToken(newUser.Guid, this.GetEmailValidationLink()); } } if (!EmailValidationRequired) { this.ViewBag.Messages = new List <string>() { "Registration successful. You can now log in with your new account" }; return(this.View("Login")); } else { return(this.RedirectToAction(nameof(EmailValidationRequired), new { Id = newUser.Guid.ToString(), area = "" })); } }
public ActionResult Index(LoginModel model) { DataTable dtlogin = WebAppDAL.UserLogin(model); LoginModel login = new LoginModel(); if (dtlogin.Rows.Count > 0 && dtlogin != null) { login.UserID = Convert.ToInt32(dtlogin.Rows[0]["UserID"]); login.UserName = Convert.ToString(dtlogin.Rows[0]["Username"]); ProjectSession.clientID = login.UserID; ProjectSession.EmailAddress = model.EmailAddress; ProjectSession.UserName = login.UserName; return(RedirectToAction("GetUserPost", "NewsFeed")); } else { RegistrationPageModel modal = new RegistrationPageModel(); List <Types> types = new List <Types>(); types.Add(new Types { UserID = 1, UserType = "Select Type" }); types.Add(new Types { UserID = 2, UserType = "Admin" }); types.Add(new Types { UserID = 3, UserType = "User" }); modal.Types = types; ModelState.AddModelError("EmailAddress", "Please Enter Valid Username Or Password"); return(View("Login", modal)); } }
public ActionResult Index() { DataTable dt = WebAppDAL.GetUserDetails(ProjectSession.clientID); //List<RegistrationPageModel> model = new List<RegistrationPageModel>(); RegistrationPageModel model = new RegistrationPageModel(); if (dt != null && dt.Rows.Count > 0) { for (var i = 0; i < dt.Rows.Count; i++) { model.FindFriendList.Add(new FindFriendList { UserID = Convert.ToInt32(dt.Rows[i]["UserID"]), UserName = dt.Rows[i]["Username"].ToString(), EmailAddress = dt.Rows[i]["EmailAddress"].ToString(), Type = dt.Rows[i]["Usertype"].ToString() }); } } DataTable dtGetFriendRequestList = WebAppDAL.GetFriendRequestList(ProjectSession.clientID); if (dtGetFriendRequestList != null && dtGetFriendRequestList.Rows.Count > 0) { for (var i = 0; i < dtGetFriendRequestList.Rows.Count; i++) { model.RequestedList.Add(new RequestedListModel { UserID = Convert.ToInt32(dtGetFriendRequestList.Rows[i]["UserID"]), EmailAddress = dtGetFriendRequestList.Rows[i]["EmailAddress"].ToString(), UserName = dtGetFriendRequestList.Rows[i]["Username"].ToString(), Type = dtGetFriendRequestList.Rows[i]["Usertype"].ToString() }); } } DataTable dtGetFriendList = WebAppDAL.GetFriendList(ProjectSession.clientID); if (dtGetFriendList != null && dtGetFriendList.Rows.Count > 0) { for (var i = 0; i < dtGetFriendList.Rows.Count; i++) { model.FriendList.Add(new FriendList { UserID = Convert.ToInt32(dtGetFriendList.Rows[i]["UserID"]), EmailAddress = dtGetFriendList.Rows[i]["EmailAddress"].ToString(), UserName = dtGetFriendList.Rows[i]["Username"].ToString(), Type = dtGetFriendList.Rows[i]["Usertype"].ToString() }); } } return(View(model)); }
public static DataSet UserRegistration(RegistrationPageModel registration) { Database db = DatabaseFactory.CreateDatabase(); DbCommand dbCommand = db.GetStoredProcCommand("UserRegistration"); db.AddInParameter(dbCommand, "@Firstname", DbType.String, registration.FirstName); db.AddInParameter(dbCommand, "@Lastname", DbType.String, registration.LastName); db.AddInParameter(dbCommand, "@Username", DbType.String, registration.UserName); db.AddInParameter(dbCommand, "@Email", DbType.String, registration.EmailAddress); db.AddInParameter(dbCommand, "@Password", DbType.String, registration.Password); db.AddInParameter(dbCommand, "@type", DbType.String, registration.Type); return(db.ExecuteDataSet(dbCommand)); }
public ActionResult RegistrationPage(RegistrationPageModel model) { DataSet dtRegistration = WebAppDAL.UserRegistration(model); if (dtRegistration.Tables.Count > 0) { ModelState.AddModelError("EmailAddress", "This Email Address is already registered"); return(RedirectToAction("Index")); } else { return(RedirectToAction("Index")); } }
public ActionResult Index() { RegistrationPageModel model = new RegistrationPageModel(); List <Types> types = new List <Types>(); types.Add(new Types { UserID = 1, UserType = "Select Type" }); types.Add(new Types { UserID = 2, UserType = "Admin" }); types.Add(new Types { UserID = 3, UserType = "User" }); model.Types = types; return(View("Login", model)); }
public ActionResult GetMutualFriendList(int id) { DataTable dtGetMutualFriend = WebAppDAL.GetMutualFriendList(id, ProjectSession.clientID); ProjectSession.IsMutualFriendTab = true; List <RegistrationPageModel> model = new List <RegistrationPageModel>(); if (dtGetMutualFriend != null && dtGetMutualFriend.Rows.Count > 0) { for (var i = 0; i < dtGetMutualFriend.Rows.Count; i++) { RegistrationPageModel registration = new RegistrationPageModel(); registration.UserID = Convert.ToInt32(dtGetMutualFriend.Rows[i]["UserID"]); registration.EmailAddress = dtGetMutualFriend.Rows[i]["EmailAddress"].ToString(); registration.Type = dtGetMutualFriend.Rows[i]["Usertype"].ToString(); registration.UserName = dtGetMutualFriend.Rows[i]["Username"].ToString(); model.Add(registration); } } return(PartialView("_MutualFriendList", model)); }
public RegistrationPage() { InitializeComponent(); SetComponents(); BindingContext = vm = new RegistrationPageModel(); }