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."; } } }
internal UserPersonalDetails GetUserDetails(int?userId) { SqlCommand command; SqlDataReader dataReader; string sql = @"SELECT FirstName, LastName, MobileNumber from UserDetails where userid = " + userId; command = new SqlCommand(sql, conn); dataReader = command.ExecuteReader(); List <Product> AllProducts = new List <Product>(); while (dataReader.Read()) { UserPersonalDetails user = new UserPersonalDetails() { FirstName = dataReader.GetValue(0).ToString(), LastName = dataReader.GetValue(1).ToString(), MobileNumber = Convert.ToInt32(dataReader.GetValue(2).ToString()) }; dataReader.Close(); command.Dispose(); return(user); } dataReader.Close(); command.Dispose(); return(null); }
private void PopulateViewStateValue(DBManipulationsLogic db) { UserPersonalDetails user = db.GetUserDetails(Session["UserId"] as int?); UpdateFirstName.Text = user.FirstName; UpdateLastName.Text = user.LastName; UpdateMobileNumber.Text = user.MobileNumber.ToString(); }
public async Task SetPersonalDetails(UserPersonalDetails personalDetails) { this.State.SetupState.ArePersonalDetailsSet = true; this.State.Username = personalDetails.Username; this.State.EmailAddress = personalDetails.EmailAddress; this.State.Surname = personalDetails.Surname; this.State.GivenName = personalDetails.GivenName; await this.WriteStateAsync(); }
public int IsLogin(UserPersonalDetails userPersonalDetails) { var reader = this.GetReader($"select * from UserPersonalDetails where UserName='******' and CreatePassword='******'"); var IsLoggedIn = 0; while (reader.Read()) { IsLoggedIn = 1; } return(IsLoggedIn); }
public static string CommaSeparatedAddress(this UserPersonalDetails userPersonalDetails) { string[] elements = new[] { userPersonalDetails.Address.AddressLine1, userPersonalDetails.Address.AddressLine2, userPersonalDetails.Address.AddressLine3, userPersonalDetails.Address.Locality.ToTitleCase(), userPersonalDetails.Address.Postcode }; return(string.Join(", ", elements.Where(e => !string.IsNullOrEmpty(e)))); }
public void UpdateUserInfo(UserPersonalDetails user) { string sql = "update UserDetails " + "set FirstName = '" + user.FirstName + "'" + ", LastName = '" + user.LastName + "'" + ", MobileNumber = " + user.MobileNumber + " " + "where userid= " + user.UserId; SqlDataAdapter adapter = new SqlDataAdapter { UpdateCommand = new SqlCommand(sql, conn) }; adapter.UpdateCommand.ExecuteNonQuery(); }
protected void UpdateButton_Click(object sender, EventArgs e) { string updatedFirstName = UpdateFirstName.Text.ToString(); string updatedLastName = UpdateLastName.Text.ToString(); int updatedMobileNumber = Convert.ToInt32(UpdateMobileNumber.Text.ToString()); UserPersonalDetails user = new UserPersonalDetails { UserId = Session["UserId"] as int?, FirstName = updatedFirstName, LastName = updatedLastName, MobileNumber = updatedMobileNumber }; DBManipulationsLogic db = new DBManipulationsLogic(); db.UpdateUserInfo(user); }
public int WriteToDB(UserPersonalDetails user) { SqlDataAdapter adapter = new SqlDataAdapter(); string sql; sql = "Insert into Users values ('" + user.UserName + "', '" + user.UserPassword + "')"; adapter.InsertCommand = new SqlCommand(sql, conn); adapter.InsertCommand.ExecuteNonQuery(); var UserId = GetUserId(user.UserName); sql = @"INSERT INTO USERDETAILS VALUES(" + UserId + ",'" + user.FirstName + "','" + user.LastName + "','" + user.Gender + "','" + user.Address + "'," + user.MobileNumber + "," + user.ProfessionId + ",'" + user.Email + "')"; adapter.InsertCommand = new SqlCommand(sql, conn); var returnVal = adapter.InsertCommand.ExecuteNonQuery(); //return number of rows affected adapter.Dispose(); return(UserId); }
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"; } } }
public static string LocationSummary(this UserPersonalDetails userPersonalDetails) { return(LocationSummary(userPersonalDetails?.Address?.Locality, userPersonalDetails?.Address?.Postcode)); }
public static IEnumerable <string> PhoneNumbers(this UserPersonalDetails userPersonalDetails) { return((new[] { userPersonalDetails.MobilePhone, userPersonalDetails.OtherPhone }).Where(a => !string.IsNullOrEmpty(a))); }
public static string FullName(this UserPersonalDetails userPersonalDetails) { return($"{userPersonalDetails.FirstName} {userPersonalDetails.LastName}"); }
public IActionResult Post(UserPersonalDetails userPersonalDetails) { this.UserPersonalDetailDomain.UserDetailAdd(userPersonalDetails); return(Ok()); }
public IActionResult Post(UserPersonalDetails userPersonalDetails) { var isLoggedIn = this.UserLoginDomain.IsLogin(userPersonalDetails); return(Ok(isLoggedIn)); }
public void UserDetailAdd(UserPersonalDetails userPersonalDetails) { this.ExecuteNonQuery($"insert into UserPersonalDetails values ('{userPersonalDetails.UserName}','{userPersonalDetails.EmailId}','{userPersonalDetails.CreatePassword}','{userPersonalDetails.MobileNumber}','{userPersonalDetails.CurrentLocation}','{userPersonalDetails.HighestQualification}','{userPersonalDetails.CurrentPercentage}',{userPersonalDetails.SelectedCategory},'{userPersonalDetails.Resume}');')"); }