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")); } }