public ActionResult Registered(RegisteredViewModel data) { if (ModelState.IsValid) { if (db.B鳥奴.Where(x => x.Email == data.Email).Any()) { ModelState.AddModelError("", "此帳號已被註冊"); return(View(data)); } B鳥奴 bUser = new B鳥奴() { Email = data.Email, UserName = data.UserName, Password = data.Password, Tel = data.Tel }; db.B鳥奴.Add(bUser); db.SaveChanges(); return(RedirectToAction("Index", "Bird")); } return(View(data)); }
public async Task <IActionResult> OnGet(string userId = null) { if (userId == null) { var claimsIdentity = (ClaimsIdentity)User.Identity; var claim = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier); userId = claim.Value; } CustVM = new RegisteredViewModel() { DailyFoods = await _db.DailyFood.Where(c => c.UserId == userId).ToListAsync(), UserObj = await _db.ApplicationUser.FirstOrDefaultAsync(u => u.Id == userId) }; return(Page()); }
public Register() { InitializeComponent(); BindingContext = new RegisteredViewModel(Navigation); }
/// <summary> /// Конструктор с передачей контекста данных /// </summary> /// <param name="viewModel">Контекст данных</param> public RegisterView(RegisteredViewModel viewModel) : this() { DataContext = viewModel; }