protected void ValidateDetails() { if (!string.IsNullOrEmpty(Request["UserName"]) && !string.IsNullOrEmpty(Request["UserPassword"])) { DBManipulationsLogic dbLogic = new DBManipulationsLogic(); UserPersonalDetails user = new UserPersonalDetails { UserName = Request["UserName"], UserPassword = Request["UserPassword"] }; var UserId = dbLogic.UserNameExists(new UserLoginDetails { UserName = Request["UserName"], UserPassword = Request["UserPassword"] }, true); dbLogic.Dispose(); if (UserId != null) { Session["UserId"] = UserId; Session["IsUserLoggedIn"] = true; Response.Redirect("Products.aspx"); } else { HttpCookie LoginErrorCookie = Request.Cookies.Get("LoginError"); LoginErrorCookie.Value = "True"; HttpCookie LoginErrorMessageCookie = Request.Cookies.Get("LoginErrorMessage"); LoginErrorMessageCookie.Value = "Invalid Login Details Provided."; } } }
protected void ValidateDetails() { if (!string.IsNullOrEmpty(Request["UserName"]) && !string.IsNullOrEmpty(Request["UserPassword"])) { DBManipulationsLogic dbLogic = new DBManipulationsLogic(); UserPersonalDetails user = new UserPersonalDetails { UserName = Request["UserName"], UserPassword = Request["UserPassword"], Email = Request["Email"], Address = Request["Address"], MobileNumber = Convert.ToInt64(Request["MobileNumber"]), Gender = Convert.ToChar(Request["SelectedRadioGender"]), ProfessionId = Convert.ToInt32(Request["SelectedDropDownOccupation"]), FirstName = Request["FirstName"], LastName = Request["LastName"], }; if (dbLogic.UserNameExists(new UserLoginDetails { UserName = Request["UserName"], UserPassword = Request["UserPassword"] }) == null) { //if username dont exist in the db, insert into db Session["UserId"] = dbLogic.WriteToDB(user); dbLogic.Dispose(); Session["IsUserLoggedIn"] = true; Response.Redirect("Products.aspx"); } else { HttpCookie LoginErrorCookie = Request.Cookies.Get("LoginError"); LoginErrorCookie.Value = "True"; HttpCookie LoginErrorMessageCookie = Request.Cookies.Get("LoginErrorMessage"); LoginErrorMessageCookie.Value = "Username is already in use"; } } }