public static Person TryFindByEmail(string email, CrdbContext dbContext)
        {
            var person = dbContext.People.SingleOrDefault(i => i.Email == email);
            return person; 

            burada kaldın. registerdan external provider ile gelip, kullanıcı kaydını yapacaksın 
        }
        public ActionResult Register(RegisterViewModel model)
        {
            if (ModelState.IsValid == false)
                return View(model);


            Person p = new Person()
            {
                Name = model.Name,
                Email = model.Email,
                Password = model.Password,
                IsActivated = false
            };

            using (CrdbContext ctx = new CrdbContext())
            {
                PersonBL.CreatePerson(p, ctx);
            }
            AppUser appUser = AppUser.FromPerson(p); 

            IdentitySignin(appUser, null, model.RememberMe);

            if (string.IsNullOrEmpty(model.ReturnUrl))
                model.ReturnUrl = Url.Action("Index", "Home");

            return Redirect(model.ReturnUrl);
        }
        public static Person ValidateAndLoad(string email, string password, CrdbContext dbContext)
        {
            var user = dbContext.People.SingleOrDefault(i => i.Email == email);
            if (user == null)
                return null;

            if (user.Password != password)
                return null;

            return user; 
        }
        public ActionResult Signin(SignInModel model)
        {
            if (ModelState.IsValid == false)
                return View(model);

            Person signinPerson; 
            using (CrdbContext ctx = new CrdbContext())
            {
                signinPerson = PersonBL.ValidateAndLoad(model.Email, model.Password, ctx); 
            }
            if (signinPerson == null)
            {
                ModelState.AddModelError("", "Giriş yapılamadı. Lütfen bilgilerinizi kontrol edip tekrar deneyiniz.  ");
                return View(model);
            }
            AppUser appUser = AppUser.FromPerson(signinPerson);
            IdentitySignin(appUser, null, model.RememberMe);

            if (string.IsNullOrEmpty(model.ReturnUrl))
                model.ReturnUrl = Url.Action("Index", "Home");

            return Redirect(model.ReturnUrl);
        }
 public static Person TryFindById(int id, CrdbContext dbContext)
 {
     var person = dbContext.People.SingleOrDefault(i => i.Id == id);
     return person; 
 }
 public static void CreatePerson(Person person, CrdbContext dbContext)
 {
     dbContext.People.Add(person);
     dbContext.SaveChanges();
 }