コード例 #1
0
ファイル: HesapController.cs プロジェクト: ahx-code/CoffeeBuy
        public ActionResult KayitOl(KayitOlModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    // Attempt to register the user
                    MembershipCreateStatus createStatus;
                    Membership.CreateUser(model.KullaniciAdi, model.Sifre, model.Email, "Soru", "Cevabi", true, null, out createStatus);

                    if (createStatus == MembershipCreateStatus.Success)
                    {
                        AlisverisListesiniTasi(model.KullaniciAdi);

                        FormsAuthentication.SetAuthCookie(model.KullaniciAdi, false);
                        return(RedirectToAction("Index", "AnaSayfa"));
                    }
                    else
                    {
                        ModelState.AddModelError("", ErrorCodeToString(createStatus));
                    }
                }
            }catch (Exception ex) {
                ModelState.AddModelError(String.Empty, ex.Message);
            }

            return(View(model));
        }
コード例 #2
0
        public ActionResult KayitOl(KayitOlModel model)
        {
            if (ModelState.IsValid)
            {
                veriler.Kullanicilar = db.Kullanicilar.ToList();

                foreach (var kullanici in veriler.Kullanicilar)
                {
                    if (model.Kullanici == kullanici.Kullanici_ad.ToString())
                    {
                        ModelState.AddModelError("", model.Kullanici + " kullanıcı adı kullanılıyor.");
                    }

                    if (model.Email == kullanici.Mail.ToString())
                    {
                        ModelState.AddModelError("", model.Email + "  E-posta adresi kullanılıyor.");
                    }
                }



                foreach (var item in ModelState)
                {
                    if (item.Value.Errors.Count > 0)
                    {
                        return(View(model));
                    }
                }



                Kullanicilar k = new Kullanicilar();

                k.Kullanici_ad = model.Kullanici;
                k.Ad           = model.Ad;
                k.Soyad        = model.Soyad;
                k.Mail         = model.Email;
                k.Sifre        = model.Parola;
                k.Uyelik_Tarih = DateTime.Now;
                k.Yetki        = 0;


                db.Kullanicilar.Add(k);
                int sonuc = db.SaveChanges();

                if (sonuc > 0)
                {
                    return(RedirectToAction("KayitOk"));
                }
            }

            return(View(model));
        }
コード例 #3
0
        private KayitOlModel IslemBosAlanlariDoldur(KayitOlModel _kom)
        {
            using (HazirSistemIslem sis = new HazirSistemIslem())
            {
                _kom.KayitTarihi = sis.TarihGetir();

                _kom.MacAdr = sis.MacAdresGetir();

                _kom.IpAdr = sis.IpAdrGetir();
            }

            return(_kom);
        }
コード例 #4
0
        private KayitOlModel OyleBirKisiVarMi(KayitOlModel _kom)
        {
            using (UyeKayitIslem uk = new UyeKayitIslem())
            {
                switch (uk.EPostaVarMi(_kom.email))
                {
                case VarYok.Yok:
                    break;

                case VarYok.Var:
                    ModelState.AddModelError("", "Bu EPosta adresi alınmış. Başka bir tane deneyin..");
                    break;

                default:
                    throw new ApplicationException("Kayıt olurken deger gelmedi");
                }
            }

            return(_kom);
        }
コード例 #5
0
 private bool KisiKaydet(KayitOlModel _kom)
 {
     throw new NotImplementedException();
 }
コード例 #6
0
        public IActionResult UyeOl(KayitOlModel _kom)
        {
            if (ModelState.IsValid)
            {
                _kom = OyleBirKisiVarMi(_kom);

                if (ModelState.IsValid)
                {
                    _kom = IslemBosAlanlariDoldur(_kom);

                    if (ModelState.IsValid)
                    {
                        if (KisiKaydet(_kom))
                        {
                            ViewBag.Script = "$(function () {$('#exampleModal').modal('show');});";
                            ViewBag.Sonuc  = "<div class='modal fade' id='exampleModal' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>"
                                             + "<div class='modal-dialog' role='document'>"
                                             + "<div class='modal-content'>"
                                             + "<div class='modal-header'>"
                                             + "<h5 class='modal-title' id='exampleModalLabel'>Kayıt Başarılı</h5>"
                                             + "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>"
                                             + "<span aria-hidden='true'>&times;</span>"
                                             + "</button>"
                                             + "</div>"
                                             + "<div class='modal-body'> Başarılı bir şekilde kayıt oldunuz. Telefonunuza gelen doğrulama kodu ile üye girişi yapabilirsiniz. </div>"
                                             + "<div class='modal-footer'>"
                                             + "<a href='javascript:base.GeriGit();' class='btn btn-secondary'>Geri Git</a>"
                                             + "<a href='javascript:base.AnaSayfaGit();' class='btn btn-primary'>Ana Sayfa</a>"
                                             + "</div>"
                                             + "</div>"
                                             + "</div>"
                                             + "</div>";
                        }
                        else
                        {
                            ViewBag.Script = "$(function () {$('#exampleModal').modal('show');});";
                            ViewBag.Sonuc  = "<div class='modal fade' id='exampleModal' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>"
                                             + "<div class='modal-dialog' role='document'>"
                                             + "<div class='modal-content'>"
                                             + "<div class='modal-header'>"
                                             + "<h5 class='modal-title' id='exampleModalLabel'>Kayıt Başarısız</h5>"
                                             + "<button type='button' class='close' data-dismiss='modal' aria-label='Close'>"
                                             + "<span aria-hidden='true'>&times;</span>"
                                             + "</button>"
                                             + "</div>"
                                             + "<div class='modal-body'> Sistem servis dışı.. Lütfen daha sonra tekrar deneyiniz. </div>"
                                             + "<div class='modal-footer'>"
                                             + "<a href='javascript:base.GeriGit();' class='btn btn-secondary'>Geri Git</a>"
                                             + "<a href='javascript:base.AnaSayfaGit();' class='btn btn-primary'>Ana Sayfa</a>"
                                             + "</div>"
                                             + "</div>"
                                             + "</div>"
                                             + "</div>";
                        }

                        return(View("MesajVer"));
                    }
                }
            }

            return(View(_kom));
        }