示例#1
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    using (BilgiYarismasiEntities2 ent = new DAL.BilgiYarismasiEntities2())
                    {
                        Kullanici kul = new Kullanici();
                        kul.Ad             = model.Ad;
                        kul.Soyad          = model.Soyad;
                        kul.Id             = new Guid(user.Id);
                        kul.EPosta         = model.Email;
                        kul.KayitTarihi    = DateTime.Now;
                        kul.DuzeltmeTarihi = DateTime.Now;

                        ent.Kullanici.Add(kul);
                        ent.SaveChanges();
                    }

                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
示例#2
0
        // GET: Profil
        public ActionResult Index()
        {
            ProfilIndexViewModel model = new ProfilIndexViewModel();

            model.ToplamYarismaSayisi = 0;
            model.ToplamDogruSayisi   = 0;
            model.ToplamYanlisSayisi  = 0;
            model.SingleBasariPuani   = 0;

            using (BilgiYarismasiEntities2 ent = new DAL.BilgiYarismasiEntities2())
            {
                Guid userId = Guid.Parse(User.Identity.GetUserId());
                model.kullanici = ent.Kullanici
                                  .Where(p => p.Id == userId)
                                  .FirstOrDefault();

                var yarismalar = ent.Yarisma.Where(p => p.MasaKullanici.KullaniciId == userId).ToList();
                model.ToplamYarismaSayisi = yarismalar.Count();

                List <YarismaSoru> yarismaSorular = ent.YarismaSoru
                                                    .Where(p => p.Yarisma.MasaKullanici.KullaniciId == userId &&
                                                           ent.Yarisma.Where(r => r.MasaKullanici.KullaniciId == userId).Any(t => t.Id == p.YarismaId))
                                                    .ToList();

                model.ToplamDogruSayisi = yarismaSorular.Where(p => p.CevapId != null && p.Cevap.Dogrumu).Count();

                model.ToplamYanlisSayisi = yarismaSorular
                                           .Where(p => p.CevapId != null && !p.Cevap.Dogrumu)
                                           .Count();

                var singleSorular = yarismaSorular.Where(p => p.Yarisma.MasaKullanici.Masa.Tip == (int)EnmMasaTipi.SinglePlaeyerMasa).ToList();
                var multiSorular  = yarismaSorular.Where(p => p.Yarisma.MasaKullanici.Masa.Tip == (int)EnmMasaTipi.MultiPlayerMasa).ToList();

                model.SingleBasariPuani = singleSorular.Sum(p => p.Puan).HasValue ? singleSorular.Sum(p => p.Puan).Value : 0;
            }

            return(View(model));
        }