public IActionResult DoRegister(string UserName, string Password, string FirstName, string LastName, string GenderValue, string Adres, string ZipCode, string DOB, string Phone, string Email) { tbl_userdata user = new tbl_userdata(); user.fld_username = UserName; user.fld_password = Password; user.fld_firstname = FirstName; user.fld_lastname = LastName; user.fld_gender = GenderValue; user.fld_address = Adres; user.fld_zipcode = ZipCode; user.fld_dateofbirth = DOB; user.fld_phonenumber = Phone; user.fld_email = Email; int emailIsTaken = MollShopContext.CheckIfUserExists(user.fld_email); if (emailIsTaken == 0) { int userNameExistance = MollShopContext.CheckIfUserNameIsTaken(user.fld_username); switch (userNameExistance) { case 0: user.fld_adminPriv = "N"; string activationToken = MollShopContext.RegisterNewUser(user); if (activationToken == "Db Error!") { ViewData["message"] = "Something went wrong on our end. Please contact support."; break; } SendVerificationLink(activationToken, user.fld_email); return(View("Login", new LoginModel())); case 1: ViewData["message"] = "This user name is already in use!"; break; default: ViewData["message"] = "Something went wrong on our end. Please contact support."; break; } return(View("Register", user)); } else { ViewData["message"] = "This email address has already been registered"; return(View("Register", user)); } }
public IActionResult Register(string UserName, string Password, string FirstName, string LastName, string GenderValue, string Adres, string ZipCode, string DOB, string Phone, string Email) { User user = new User(UserName, Password, FirstName, LastName, GenderValue, Adres, ZipCode, DOB, Phone, Email); LoginModel loginMdl = new LoginModel(Email, Password); MollShopContext context = HttpContext.RequestServices.GetService(typeof(TestWebApp.Models.MollShopContext)) as MollShopContext; int userExists = context.CheckIfUserExists(loginMdl); if (userExists == 0) { context.RegisterNewUser(user); return(RedirectToAction("LI_index", "Page")); } return(View()); }