示例#1
0
        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));
        }
示例#2
0
        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());
        }
示例#3
0
 public Register()
 {
     InitializeComponent();
     BindingContext = new RegisteredViewModel(Navigation);
 }
示例#4
0
 /// <summary>
 /// Конструктор с передачей контекста данных
 /// </summary>
 /// <param name="viewModel">Контекст данных</param>
 public RegisterView(RegisteredViewModel viewModel)
     : this()
 {
     DataContext = viewModel;
 }