public async Task <IActionResult> OnPostRegister() { SelectListItem s = GenderL.Where(p => p.Selected).FirstOrDefault(); string g = s.ToString(); /* SelectListItem s = Countries.Where(p => p.Selected).FirstOrDefault(); * //if(s!=null) * List<country> cnList = SessionHelpers.GetObject<List<country>>(HttpContext.Session, "_country"); * country c = cnList.Where(p => p.CountryID == int.Parse(s.Value)).First<country>();*/ if (g == "Male") { Sex = 1; } else if (g == "Female") { Sex = 0; } else if (g == "Other") { Sex = 2; } if (!await _communicationService.CheckLogin(Username, Password)) { int uid = await _communicationService.Register1(Name, Sex, Dob, Username, Password, Height, Weight); if (uid > 0) { DietSite.User user = new User(); user.UserID = uid; user.Name = Name; user.Sex = Sex; user.DOB = Dob; user.Username = Username; user.Password = Password; user.Height = Height; user.Weight = Weight; SessionHelpers.StoreObject(HttpContext.Session, Constant.IsLoggedIn, true); SessionHelpers.StoreObject(HttpContext.Session, Constant.UserDetails, user); return(RedirectToPage("Index")); } else { RegisterMessage = "There is some problem registering"; return(Page()); } } else { return(RedirectToPage("Login")); } }
public async Task <IActionResult> OnGetSignIn() { if (await _communicationService.CheckLogin(Username, Password)) { List <User> users = await _communicationService.getuserdetails(Username); DietSite.User u = users.Where(p => p.Username == Username).FirstOrDefault <User>(); SessionHelpers.StoreObject(HttpContext.Session, Constant.IsLoggedIn, true); SessionHelpers.StoreObject(HttpContext.Session, Constant.UserDetails, u); LoginMessage = "Successfully Logged In"; if (HttpContext.Session.Keys.Contains(Constant.RedirectPage)) { string page = SessionHelpers.GetObject <string>(HttpContext.Session, Constant.RedirectPage); HttpContext.Session.Remove(Constant.RedirectPage); return(RedirectToPage(page)); } return(RedirectToPage("Index")); } else { LoginMessage = "UserID or Password is incorrect"; return(Page()); } }