Ejemplo n.º 1
0
        public ActionResult Register(AppUserVM apvm)
        {
            if (!ModelState.IsValid)
            {
                return(View("Register"));
            }

            apvm.AppUser.Password = DantexCrypt.Crypt(apvm.AppUser.Password);

            apvm.AppUser.ConfirmPassword = DantexCrypt.Crypt(apvm.AppUser.ConfirmPassword);



            if (apRep.Any(x => x.Email == apvm.AppUser.Email))
            {
                ViewBag.Mevcut = "Bu Email adresine kayıtlı hesap bulunmaktadır.";
                return(View());
            }
            string gonderilecekMail = "Tebrikler kayıt olma işleminiz başarılı bir şekilde gerçekleştirilmiştir. Hesabınızı aktif etmek için https://localhost:44390/Account/Activation/" + apvm.AppUser.ActivationCode + " linkine tıklamanız yeterlidir.";

            MailSender.Send(apvm.AppUser.Email, body: gonderilecekMail, subject: "Hesap Aktivasyon");

            apRep.Add(apvm.AppUser); //One to one relation on first

            if (!string.IsNullOrEmpty(apvm.UserProfile.FirstName) || !string.IsNullOrEmpty(apvm.UserProfile.LastName) || apvm.UserProfile.Gender != 0 || !string.IsNullOrEmpty(apvm.UserProfile.MobilePhone))
            {
                apvm.UserProfile.ID = apvm.AppUser.ID;
                apdRep.Add(apvm.UserProfile);
            }

            return(View("RegisterOk"));
        }
Ejemplo n.º 2
0
        protected override void Seed(MyContext context)
        {
            #region Admin


            AppUser au = new AppUser();
            au.UserName = "******";
            au.Password = DantexCrypt.Crypt("123");
            au.Email    = "*****@*****.**";
            au.Role     = ENTITIES.Enums.UserRole.Admin;
            context.AppUsers.Add(au);
            context.SaveChanges();



            #endregion



            for (int i = 0; i < 10; i++)
            {
                AppUser ap = new AppUser();
                ap.UserName = new Internet("tr").UserName();
                ap.Password = new Internet("tr").Password();
                ap.Email    = new Internet("tr").Email();
                context.AppUsers.Add(ap);
            }
            context.SaveChanges();

            for (int i = 2; i < 12; i++)
            {
                UserProfile up = new UserProfile();
                up.ID        = i;//Birebir ilişki oldugundan dolayı üst tarafta olusturulan AppUser'ların ID'leri ile buraları eşleşmeli...O yüzden döngünün iterasyonunu 2'den baslattık...
                up.FirstName = new Name("tr").FirstName();
                up.LastName  = new Name("tr").LastName();
                up.Address   = new Address("tr").Locale;
                context.Profiles.Add(up);
            }
            context.SaveChanges();

            for (int i = 0; i < 10; i++)
            {
                Category c = new Category();
                c.CategoryName = new Commerce("tr").Categories(1)[0];
                c.Description  = new Lorem("tr").Sentence(10);

                for (int j = 0; j < 30; j++)
                {
                    Product p = new Product();
                    p.ProductName  = new Commerce("tr").ProductName();
                    p.UnitPrice    = Convert.ToDecimal(new Commerce("tr").Price());
                    p.UnitsInStock = 100;
                    p.ImagePath    = new Images().Nightlife();
                    c.Products.Add(p);
                }

                context.Categories.Add(c);
                context.SaveChanges();
            }
        }
        public ActionResult RegisterNow(UserCardVM apvm)
        {
            UserCard    userCard    = apvm.UserCard;
            CompanyCard companyCard = apvm.CompanyCard;

            userCard.Password = DantexCrypt.Crypt(userCard.Password); //sifreyi kriptoladık

            if (_usRep.Any(x => x.UserName == userCard.UserName))
            {
                ViewBag.ZatenVar = "Kullanıcı ismi daha önce alınmıs";
                return(View());
            }
            else if (_usRep.Any(x => x.Email == userCard.Email))
            {
                ViewBag.ZatenVar = "Email zaten kayıtlı";
                return(View());
            }

            //Kullanıcı basarılı bir şekilde register işlemini tamamladıysa ona mail gonder...

            string gonderilecekMail = "Tebrikler...Hesabınız olusturulmustur...Hesabınızı aktive etmek icin https://localhost:44392/Register/Activation/" + userCard.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(userCard.Email, body: gonderilecekMail, subject: "Hesap aktivasyon!");
            _usRep.Add(userCard); //öncelikle bunu eklemelisiniz...Cünkü AppUser'in ID'si ilk basta olusmalı...Cünkü siz birebir ilişkide AppUser zorunlu olan alan Profile ise opsiyonal alan olarak olusturdunuz... Dolayısıyla ilk basta AppUser'in ID'si SaveChanges ile olusmalı


            if (!string.IsNullOrEmpty(companyCard.CompanyName) || !string.IsNullOrEmpty(companyCard.Phone) || !string.IsNullOrEmpty(companyCard.Address))
            {
                companyCard.ID = userCard.ID;
                _ccRep.Add(companyCard);
            }

            return(View("RegisterOk"));
        }
Ejemplo n.º 4
0
        public ActionResult Login(AppUser appUser)
        {
            AppUser yakalanan = _apRep.FirstOrDefault(x => x.UserName == appUser.UserName);

            if (yakalanan == null)
            {
                ViewBag.Kullanici = "Kullanıcı bulunamadı";
                return(View());
            }
            string decrypted = DantexCrypt.DeCrypt(yakalanan.Password);

            if (appUser.Password == decrypted && yakalanan.Role == ENTITIES.Enums.UserRole.Admin)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["admin"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category", new { Area = "Admin" }));
            }
            else if (yakalanan.Role == ENTITIES.Enums.UserRole.Member)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["member"] = yakalanan;
                return(RedirectToAction("ShoppingList", "Shopping"));
            }

            ViewBag.Kullanici = "Kullanici bulunamadı";
            return(View());
        }
        public ActionResult RegisterNow(AppUser AppUser, AppUserDetail AppUserDetail)
        {
            AppUser.Password = DantexCrypt.Crypt(AppUser.Password);

            //AppUser.Password = DantexCrypt.DeCrypt(AppUser.Password);

            if (apRep.Any(x => x.UserName == AppUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanıcı ismi daha önce alınmıs";
                return(View());
            }
            else if (apRep.Any(x => x.Email == AppUser.Email))
            {
                ViewBag.ZatenVar = "Email zaten kayıtlı";
                return(View());
            }
            //Kullanıcı basarılı bir sekilde register işlemini tamamlıyorsa ona mail gönder

            string gonderilecekMail = "Tebrikler.. Hesabınız olusturulmustur.. Hesabınızı aktive etmek icin http://localhost:55735/Register/Activation/" + AppUser.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(AppUser.Email, body: gonderilecekMail, subject: "Hesap aktivasyon!");
            apRep.Add(AppUser); //buradan sonra AppUser'in identity olan id'si olusmus oluyor... O yüzden AppUserDetail'nin id'sini verecek isek ve olusturacak isek buradan vermeliyiz.

            if (!string.IsNullOrEmpty(AppUserDetail.FirstName) || !string.IsNullOrEmpty(AppUserDetail.LastName) || !string.IsNullOrEmpty(AppUserDetail.Address))
            {
                AppUserDetail.ID = AppUser.ID;
                apdRep.Add(AppUserDetail);
            }

            return(View("RegisterOk"));
        }
Ejemplo n.º 6
0
        public ActionResult Login([Bind(Prefix = "AppUser")] AppUser item)
        {
            AppUser yakalanan = apRep.FirstOrDefault(x => x.UserName == item.UserName);
            string  decrypted = DantexCrypt.DeCrypt(yakalanan.Password);

            if (item.Password == decrypted && yakalanan != null && yakalanan.Role == ENTITIES.Enum.UserRole.Admin)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["admin"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category"));
            }
            else if (yakalanan.Role == ENTITIES.Enum.UserRole.Member)
            {
                if (!yakalanan.Active)
                {
                    return(AktifKontrol());
                }
                Session["member"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category"));
            }
            ViewBag.KullaniciYok = "Kullanici Bulunamadi";
            return(View());
        }
        public ActionResult Login(UserCard userCard)
        {
            UserCard uye = _usRep.FirstOrDefault(x => x.UserName == userCard.UserName);

            string decrypted = DantexCrypt.DeCrypt(uye.Password);

            if (userCard.Password == decrypted && uye != null)
            {
                if (uye.Role == ENTITIES.Enums.UserCardRole.Admin)
                {
                    if (!uye.Active)
                    {
                        return(AktifKontrol());
                    }
                    Session["admin"] = uye;
                    return(RedirectToAction("CategoryList", "Category", new { area = "Admin" }));
                }


                else
                {
                    ViewBag.RolBelirsiz = "Rol belirlenmemiş";
                    return(View());
                }
            }

            ViewBag.KullaniciYok = "Kullanıcı bulunamadı";
            return(View());
        }
Ejemplo n.º 8
0
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.UserProfile;

            appUser.Password = DantexCrypt.Crypt(appUser.Password); //sifreyi kriptoladık

            //AppUser.Password = DantexCrypt.DeCrypt(apvm.AppUser.Password);

            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanıcı ismi daha önce alınmıs";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Email zaten kayıtlı";
                return(View());
            }

            //Kullanıcı basarılı bir şekilde register işlemini tamamladıysa ona mail gönder

            string gonderilecekMail = "Tebrikler...Hesabınız olusturulmustur. Hesabınızı aktive etmek icin https://localhost:44389/Register/Activation/" + appUser.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(appUser.Email, body: gonderilecekMail, subject: "Hesap aktivasyon!");
            apRep.Add(appUser); //öncelikle bunu eklemelisiniz. Cnkü AppUser'in ID'si ilk basta olusmalı... Cünkü biz birebir ilişkide AppUser zorunlu alan Profile ise opsiyonel alandır. Dolayısıyla ilk basta AppUser'in ID'si SaveChanges ile olusmalı ki sonra Profile'i rahatca ekleyebilelim...

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName) || !string.IsNullOrEmpty(profile.Address))
            {
                profile.ID = appUser.ID;
                apdRep.Add(profile);
            }

            return(View("RegisterOk"));
        }
        public ActionResult Index(AppUser appUser, AppUserDetail appUserDetail)
        {
            appUser.Password = DantexCrypt.Crypt(appUser.Password);
            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Bu kullanıcı ismi daha önce alınmış!";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Bu Email Zaten Kayıtlı";
                return(View());
            }
            string sendMail = "Tebrikler, hesabınız oluşturuldu. Hesabınızı Aktive etmek için http://localhost:54696/Register/Activation/" + appUser.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(appUser.Email, body: sendMail, subject: "Hesap Aktivasyon!");
            apRep.Add(appUser);

            if (!string.IsNullOrEmpty(appUserDetail.FirstName) || !string.IsNullOrEmpty(appUserDetail.LastName) || !string.IsNullOrEmpty(appUserDetail.Adress1) || !string.IsNullOrEmpty(appUserDetail.Adress2))
            {
                appUserDetail.ID = appUser.ID;
                apdRep.Add(appUserDetail);
            }
            return(View("RegisterOk"));
        }
Ejemplo n.º 10
0
        public ActionResult Login(AppUser item)
        {
            #region EskiAlgoritma
            //if (arep.Any(x=>x.UserName == item.UserName && x.Password==item.Password && x.IsActive == true && x.Role == UserRole.Member))
            //{
            //    Session.Add("member",arep.Where(x => x.UserName == item.UserName && x.Password == item.Password && x.IsActive == true && x.Role == UserRole.Member));
            //    return RedirectToAction("ProductList", "Member");  // todo: sonradan eklendi
            //}

            // Furkan Test Islemlerı Test1 :)
            #endregion

            try
            {
                foreach (AppUser item2 in arep.GetAll())
                {
                    string cozulmusSifre = DantexCrypt.DeCrypt(item2.Password);
                    if (arep.Any(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Member) == true)
                    {
                        Session["member"] = arep.Where(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Member).FirstOrDefault();

                        AppUser kullanici = Session["member"] as AppUser;
                        return(RedirectToAction("ProductList", "Member"));
                    }
                }

                ViewBag.Hatali = "Kullanıcı Bilgileri Hatalı. Kayıtlı Değilseniz: ";
                return(View());
            }
            catch (Exception)
            {
                ViewBag.Hatali = "Kullanıcı Bilgileri Hatalı. Kayıtlı Değilseniz: ";
                return(View());
            }
        }
Ejemplo n.º 11
0
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.Profile;

            appUser.Password = DantexCrypt.Crypt(appUser.Password);

            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanici ismi daha onceden alinmis";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Email adresi daha onceden alinmis";
                return(View());
            }

            string gonderilecekMail = "Tebrikler. Hesabiniz olusturuldu. Hesabinizi aktif etmek icin lutfen baglantiya tiklayin. https://localhost:44318/Register/Activation/" + appUser.ActivationCode;

            MailSender.Send(appUser.Email, password: "******", body: gonderilecekMail, subject: "Hesap Aktivasyon", sender: "*****@*****.**");
            apRep.Add(appUser);

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName))
            {
                profile.ID = appUser.ID;
                apdRep.Add(profile);
            }
            return(View("RegisterOk"));
        }
Ejemplo n.º 12
0
        public ActionResult Login(AppUser item)
        {
            try
            {
                foreach (AppUser item2 in arep.GetAll())
                {
                    string cozulmusSifre = DantexCrypt.DeCrypt(item2.Password);

                    if (arep.Any(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Admin) == true)
                    {
                        Session["admin"] = arep.Where(x => x.UserName == item.UserName && cozulmusSifre == item.Password && x.IsActive == true && x.Role == UserRole.Admin).FirstOrDefault();

                        AppUser kullanici = Session["admin"] as AppUser;
                        return(RedirectToAction("ListProduct", "Product"));
                    }
                }

                ViewBag.Hatali = "Hatalı giriş yaptınız.";
                return(View());
            }
            catch (Exception)
            {
                ViewBag.Hatali = "Hatalı giriş yaptınız";
                return(View());
            }
        }
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.Profile;

            appUser.Password = DantexCrypt.Crypt(appUser.Password); //sifreyi kriptoladık

            //AppUser.Password = DantexCrypt.DeCrypt(apvm.AppUser.Password);

            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "This username is already taken";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "This email is already registered";
                return(View());
            }

            //Kullanıcı basarılı bir şekilde register işlemini tamamladıysa ona mail gönder

            string gonderilecekMail = "Congratulations...Your account has been created. You can click the https://localhost:44362/Register/Activation/" + appUser.ActivationCode + " link to activate your account..";

            MailSender.Send(appUser.Email, body: gonderilecekMail, subject: "Account activation!");
            apRep.Add(appUser); //öncelikle bunu eklemelisiniz. Cnkü AppUser'in ID'si ilk basta olusmalı... Cünkü biz birebir ilişkide AppUser zorunlu alan Profile ise opsiyonel alandır. Dolayısıyla ilk basta AppUser'in ID'si SaveChanges ile olusmalı ki sonra Profile'i rahatca ekleyebilelim...

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName) || !string.IsNullOrEmpty(profile.Address))
            {
                profile.ID = appUser.ID;
                apdRep.Add(profile);
            }

            return(View("RegisterOk"));
        }
Ejemplo n.º 14
0
        protected override void Seed(MyContext context)
        {
            //Admin ekleme
            AppUser ap = new AppUser();

            ap.UserName = "******";
            ap.Password = DantexCrypt.Crypt("1234");
            ap.Email    = "*****@*****.**";
            ap.Role     = ENTITIES.Enum.UserRole.Admin;
            ap.Active   = true;
            context.AppUsers.Add(ap);
            context.SaveChanges();



            for (int i = 0; i < 10; i++)
            {
                AppUser apu = new AppUser();
                apu.UserName = new Internet("tr").UserName();
                apu.Password = new Internet("tr").Password();
                apu.Email    = new Internet("tr").Email();

                context.AppUsers.Add(apu);
            }
            context.SaveChanges();

            for (int i = 2; i < 12; i++)
            {
                UserProfile up = new UserProfile();
                up.ID        = i;
                up.FirstName = new Name("tr").FirstName();
                up.LastName  = new Name("tr").LastName();

                context.UserProfiles.Add(up);
            }

            context.SaveChanges();


            for (int i = 0; i < 10; i++)
            {
                Category c = new Category();
                c.CategoryName = new Commerce("tr").Categories(1)[0];
                c.Description  = new Lorem("tr").Sentence(10);
                c.ImagePath    = new Images().Nightlife();
                for (int j = 0; j < 15; j++)
                {
                    Article a = new Article();
                    a.ArticleHeader  = new Lorem("tr").Sentence(2);
                    a.ArticleContent = new Lorem("tr").Sentence(10);


                    c.Articles.Add(a);
                }

                context.Categories.Add(c);
                context.SaveChanges();
            }
        }
Ejemplo n.º 15
0
        public ActionResult Login(AppUser item)
        {
            if (arep.Any(x => x.UserName == item.UserName && DantexCrypt.DeCrypt(x.Password) == item.Password && x.Role == MODEL.Enums.UserRole.Admin))
            {
                Session["admin"] = arep.FirstOrDefault(x => x.UserName == item.UserName && x.Password == item.Password && x.Role == MODEL.Enums.UserRole.Admin);

                return(RedirectToAction("ListProduct", "Product"));
            }
            ViewBag.Hata = "Hatalı Giriş Yaptınız.";
            return(View());
        }
 public AppUser KontrolEt(string kullaniciadi, string sifre)
 {
     foreach (AppUser item in db.AppUsers.Where(x => x.IsActive == true))
     {
         string veritabaniSifre = DantexCrypt.DeCrypt(item.Password);
         if (Any(x => x.UserName == kullaniciadi && veritabaniSifre == sifre && x.Role == UserRole.Member && x.IsActive == true))
         {
             return(Where(x => x.UserName == kullaniciadi && veritabaniSifre == sifre && x.Role == UserRole.Member && x.IsActive == true).Single());
         }
     }
     return(null);
 }
Ejemplo n.º 17
0
        public ActionResult ResetPassword([Bind(Prefix = "AppUser")] AppUser item)
        {
            if (!ModelState.IsValid) //Server Side Validation
            {
                return(View());
            }
            AppUser toBeUpdated = apRep.FirstOrDefault(x => x.ActivationCode == item.ActivationCode);

            toBeUpdated.Password        = DantexCrypt.Crypt(item.Password);
            toBeUpdated.ConfirmPassword = DantexCrypt.Crypt(item.ConfirmPassword);
            apRep.Update(toBeUpdated);

            TempData["ResetInfo"] = "Şifreniz başarılı bir şekilde güncellenmiştir.";

            return(RedirectToAction("Login"));
        }
Ejemplo n.º 18
0
        public ActionResult ResetPassword(AppUser appUser)//TODO : toBeUpdated Null geliyor bakılacak.
        {
            //ModelState.Remove("AppUser.UserName");
            if (!ModelState.IsValid)
            {
                return(View());
            }
            AppUser toBeUpdated = appRep.FirstOrDefault(x => x.ActivationCode == appUser.ActivationCode);

            //toBeUpdated = appRep.Find(appUser.id);
            toBeUpdated.Password        = DantexCrypt.Crypt(appUser.Password);
            toBeUpdated.ConfirmPassword = DantexCrypt.Crypt(appUser.ConfirmPassword);
            appRep.Update(toBeUpdated);

            TempData["Reset"] = "Şifre sıfırlama işleminiz başarılı bir şekilde gerçekleştirilmiştir.";

            return(RedirectToAction("Login"));
        }
Ejemplo n.º 19
0
        public ActionResult Login(AppUser item)
        {
            AppUser yakalanan = apRep.Default(x => x.UserName == item.UserName);

            string decrypted = DantexCrypt.DeCrypt(yakalanan.Password);

            if (item.Password == decrypted && yakalanan != null && yakalanan.Role == MODEL.Enums.UserRole.Admin)
            {
                if (!yakalanan.IsActive)
                {
                    AktifKontrol();
                }
                Session["admin"]     = yakalanan;
                Session["LogMember"] = yakalanan;
                return(RedirectToAction("CategoryList", "Category", new { area = "Admin" }));
            }

            else if (item.Password == decrypted && yakalanan != null && yakalanan.Role == MODEL.Enums.UserRole.Member)
            {
                if (!yakalanan.IsActive)
                {
                    AktifKontrol();
                }

                Session["member"]    = yakalanan;
                Session["LogMember"] = yakalanan;
                return(RedirectToAction("ShoppingList", "Shopping"));
            }

            if (yakalanan != null)
            {
                LogRepository lrep        = new LogRepository();
                Log           sifreYanlis = new Log();
                sifreYanlis.Description = KeyWord.Exit;
                sifreYanlis.Information = $"{item.UserName} adlı kullanıcı şifresini {DateTime.Now} tarihinde yanlış girdi.";
                lrep.Add(sifreYanlis);
            }



            TempData["KullaniciYok"] = "Kullanıcı veya şifre yanlış.";
            return(View());
        }
Ejemplo n.º 20
0
        public ActionResult Login([Bind(Prefix = "AppUser")] AppUser item)
        {
            AppUser loginUser = apRep.FirstOrDefault(x => x.Email == item.Email);


            if (loginUser == null) //Eğer sorgudan kullanıcı gelmiyorsa
            {
                ViewBag.Hata = "Bu email adresine kayıtlı kullanıcı bulunamadı";
                return(View());
            }

            string decrypted = DantexCrypt.DeCrypt(loginUser.Password);



            if (loginUser != null && item.Password == decrypted && loginUser.Role == ENTITIES.Enums.UserRole.Member)
            {
                if (!loginUser.Active)
                {
                    return(AktifKontrol());
                }
                Session["member"] = loginUser;
                return(RedirectToAction("Index", "Home"));
            }//If catched user is a member
            else if (loginUser != null && item.Password == decrypted && loginUser.Role == ENTITIES.Enums.UserRole.Vip)
            {
                if (!loginUser.Active)
                {
                    return(AktifKontrol());
                }
                Session["vip"] = loginUser;
                return(RedirectToAction("Index", "Home"));
            }//If catched user is a vip



            else
            {
                ViewBag.Hata = "Email adresi veya şifrenizi hatalı girdiniz.";
                return(View());
            }
        }
Ejemplo n.º 21
0
        public ActionResult EmployeeLogin([Bind(Prefix = ("Employee"))] Employee item)
        {
            Employee loginEmployee = _empRep.FirstOrDefault(x => x.Email == item.Email);

            string decrypted = DantexCrypt.DeCrypt(loginEmployee.Password);

            if (loginEmployee == null)
            {
                ViewBag.Hata = "Bu email adresine kayıtlı çalışan bulunamadı";
                return(View());
            }
            else
            {
                if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.Boss)
                {
                    Session["boss"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a boss
                else if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.Management)
                {
                    Session["management"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a management
                else if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.BookingClerk)
                {
                    Session["bookingClerk"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a bookingClerk
                else if (loginEmployee != null && item.Password == decrypted && loginEmployee.EmployeeType == ENTITIES.Enums.EmployeeType.BoxOfficeSupervisor)
                {
                    Session["boxSupervisor"] = loginEmployee;
                    return(RedirectToAction("Index", "Main"));
                }//If catched user is a boxSupervisor
                else
                {
                    ViewBag.Hata = "Email adresi veya şifrenizi hatalı girdiniz.";
                    return(View());
                }
            }
        }
Ejemplo n.º 22
0
        public ActionResult Login(AppUser item)
        {
            AppUser user      = apRep.Default(x => x.UserName == item.UserName);
            string  decrypted = DantexCrypt.DeCrypt(user.Password);

            if (item.Password == decrypted && user != null)
            {
                if (user.Role == UserRole.Admin)
                {
                    if (!user.IsActive)
                    {
                        ActiveControl();
                    }
                    else
                    {
                        Session["admin"] = user;
                        return(RedirectToAction("Index", "AdminHome", new { area = "Admin" }));
                    }
                }
                else if (user.Role == UserRole.Member)
                {
                    if (!user.IsActive)
                    {
                        ActiveControl();
                    }
                    else
                    {
                        Session["member"] = user;
                        return(RedirectToAction("Index", "Shopping"));
                    }
                }
            }
            else
            {
                ViewBag.UserNull = "Kullanıcı Bulunamadı";
            }
            return(View(user));
        }
        public ActionResult Add([Bind(Prefix = "item1")] AppUser item, [Bind(Prefix = "item2")] AppUserDetail item2)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }   //Kullanıcı tarayıcının JS kapatıp giriş yapmak isteyebilir.

            if (item != null && item2 != null)
            {
                if (arep.Any(x => x.UserName != item.UserName && DantexCrypt.DeCrypt(x.Password) != item.Password && x.Email != item.Email))
                {
                    item.Role = UserRole.Admin;
                    arep.Add(item);
                    item2.ID = item.ID;
                    adrep.Add(item2);
                    MailSender.Send(item.Email, body: $"{"http://localhost:60442/Home/RegisterOnay/"}{item.ActivationCode}", subject: "Doğrulama Kodu");
                    return(View("List"));
                }
                ViewBag.ZatenVar = "Böyle bir kullanıcı zaten var.";
                return(View());
            }
            ViewBag.Hata = "Kullanıcı oluşturulurken hata oluştu.";
            return(View());
        }
Ejemplo n.º 24
0
        public ActionResult Login(AppUser appUser)
        {
            AppUser account = appRep.FirstOrDefault(x => x.UserName == appUser.UserName || x.Email == appUser.Email);
            //kullanıcı adı ya da email

            string decrypted = DantexCrypt.DeCrypt(account.Password);

            if (appUser.Password == decrypted && account != null && account.URole == ENTITIES.Enums.UserRole.Member)
            {
                if (!account.Active)
                {
                    return(ActiveControl());
                }

                //FormsAuthentication.SetAuthCookie(appUser.UserName, appUser.RememberMe);
                //Beni hatırla butonu için
                Session["member"] = account;
                return(RedirectToAction("ShoppingList", "Shopping"));
                //Burada ShoppingList vardı
            }

            ViewBag.KullaniciYok = "Kullanıcı Bulunamadı";
            return(View());
        }
Ejemplo n.º 25
0
        public ActionResult RegisterNow(AppUserVM apvm)
        {
            if (!ModelState.IsValid)
            {
                return(View("RegisterNow"));
            }
            AppUser     appUser = apvm.AppUser;
            UserProfile profile = apvm.UserProfile;

            appUser.Password        = DantexCrypt.Crypt(appUser.Password);
            appUser.ConfirmPassword = DantexCrypt.Crypt(appUser.ConfirmPassword);
            //Kayıt işlemi
            if (apRep.Any(x => x.UserName == appUser.UserName))
            {
                ViewBag.ZatenVar = "Kullanıcı ismi alınmış";
                return(View());
            }
            else if (apRep.Any(x => x.Email == appUser.Email))
            {
                ViewBag.ZatenVar = "Email kayıtlı";
                return(View());
            }

            //Başarılı kayıt sonrası mail gönderme işlemi
            string register = "Tebrikler, hesabınız oluşturulmuştur. Hesabınızı aktive etmek için https://localhost:44317/Register/Activation/" + appUser.ActivationCode + " linkine tıklayabilirsiniz.";

            MailSender.Send(appUser.Email, body: register, subject: "Hesap Aktivasyon!");
            apRep.Add(appUser);

            if (!string.IsNullOrEmpty(profile.FirstName) || !string.IsNullOrEmpty(profile.LastName) || !string.IsNullOrEmpty(profile.Address) || !string.IsNullOrEmpty(profile.Phone))
            {
                profile.ID = appUser.ID;
                usRep.Add(profile);
            }
            return(View("RegisterSuccess"));
        }
Ejemplo n.º 26
0
        protected override void Seed(MyContext context)
        {
            Employee au = new Employee();//Boss Tanımlama

            au.Email           = "*****@*****.**";
            au.Password        = DantexCrypt.Crypt("123");
            au.ConfirmPassword = DantexCrypt.Crypt("123");
            au.EmployeeType    = ENTITIES.Enums.EmployeeType.Boss;
            au.FirstName       = "Serkan";
            au.LastName        = "Akçay";
            au.TCNO            = "21111111111";
            au.Sallary         = 5300;
            au.MobilePhone     = "5316622582";
            context.Employees.Add(au);
            context.SaveChanges();



            AppUser vau = new AppUser();//VIP Tanımlama

            vau.Role            = ENTITIES.Enums.UserRole.Vip;
            vau.Active          = true;
            vau.Email           = "*****@*****.**";
            vau.Password        = DantexCrypt.Crypt("123456");
            vau.ConfirmPassword = DantexCrypt.Crypt("123456");
            context.AppUsers.Add(vau);


            UserProfile vup = new UserProfile();//VIP Profil Tanımlama

            vup.ID          = vau.ID;
            vup.FirstName   = "Emre";
            vup.LastName    = "Özdemir";
            vup.MobilePhone = "5345997081";
            vup.Gender      = ENTITIES.Enums.Gender.Erkek;
            context.UserProfiles.Add(vup);
            context.SaveChanges();


            Employee emp = new Employee();//BookingClerk

            emp.Email           = "*****@*****.**";
            emp.Password        = DantexCrypt.Crypt("123");
            emp.ConfirmPassword = DantexCrypt.Crypt("123");
            emp.EmployeeType    = ENTITIES.Enums.EmployeeType.BookingClerk;
            emp.FirstName       = "Ercan";
            emp.LastName        = "Karahan";
            emp.TCNO            = "21111111111";
            emp.Sallary         = 1300;
            emp.MobilePhone     = "5316622582";
            context.Employees.Add(emp);
            context.SaveChanges();

            Employee emp2 = new Employee(); //BoxOfficeSuperVisor

            emp2.EmployeeType    = ENTITIES.Enums.EmployeeType.BoxOfficeSupervisor;
            emp2.Email           = "*****@*****.**";
            emp2.Password        = DantexCrypt.Crypt("1234");
            emp2.ConfirmPassword = DantexCrypt.Crypt("1234");
            emp2.FirstName       = "Yusuf Emre";
            emp2.LastName        = "Ozdemir";
            emp2.TCNO            = "11111111111";
            emp2.Sallary         = 1301;
            emp2.MobilePhone     = "5312622582";
            context.Employees.Add(emp2);
            context.SaveChanges();

            Employee emp3 = new Employee(); //Management

            emp3.EmployeeType    = ENTITIES.Enums.EmployeeType.Management;
            emp3.Email           = "*****@*****.**";
            emp3.Password        = DantexCrypt.Crypt("serkan1903");
            emp3.ConfirmPassword = DantexCrypt.Crypt("serkan1903");
            emp3.FirstName       = "Serkan";
            emp3.LastName        = "Akçay";
            emp3.TCNO            = "11111111113";
            emp3.Sallary         = 4500;
            emp3.MobilePhone     = "5312625582";
            context.Employees.Add(emp3);
            context.SaveChanges();



            string[] genres = new string[] { "Korku", "Bilim Kurgu", "Aksiyon", "Belgesel", "Macera" };

            for (int i = 1; i <= 5; i++)
            {
                Genre genre = new Genre();
                genre.ID = i;


                genre.GenreName   = genres[i - 1];
                genre.Description = new Lorem("tr").Sentence(10);
                context.Genres.Add(genre);
            }
            context.SaveChanges();


            for (int i = 1; i <= 10; i++)
            {
                Actor actor = new Actor();
                actor.FirstName = new Name("en").FirstName();
                actor.LastName  = new Name("en").LastName();
                actor.Age       = new Random().Next(30, 50).ToString();
                actor.Country   = new Address("en").Country();
                context.Actors.Add(actor);
            }
            context.SaveChanges();

            for (int i = 1; i <= 5; i++)
            {
                Director director = new Director();
                director.FirstName = new Name("en").FirstName();
                director.LastName  = new Name("en").LastName();
                director.Age       = new Random().Next(30, 50).ToString();
                director.Country   = new Address("en").Country();
                context.Directors.Add(director);
            }
            context.SaveChanges();

            for (int i = 1; i <= 20; i++)
            {
                Movie movie = new Movie();
                movie.MovieName      = new Lorem("en").Word();
                movie.Description    = new Lorem("en").Sentences(10);
                movie.DirectorID     = new Random().Next(1, 6);
                movie.MovieYear      = new Random().Next(2005, 2020).ToString();
                movie.GenreID        = new Random().Next(1, 6);
                movie.MovieImagePath = "/Pictures/starWars.jpg";

                context.Movies.Add(movie);
            }
            context.SaveChanges();



            context.SaveChanges();


            DateTime[] sessions = new DateTime[] { Convert.ToDateTime("2021-04-17 11:00:00.000"), Convert.ToDateTime("2021-04-22 13:00:00.000"), Convert.ToDateTime("2021-05-27 14:00:00.000"), Convert.ToDateTime("2021-05-29 15:00:00.000"), Convert.ToDateTime("2021-06-12 15:00:00.000") };

            for (int i = 0; i < 5; i++)
            {
                Session session = new Session();
                session.ID            = i + 1;
                session.Time          = sessions[i];
                session.SessionActive = true;
                session.IsSpecial     = false;
                session.Price         = Convert.ToDecimal(new Commerce("tr").Price());
                context.Sessions.Add(session);
            }
            context.SaveChanges();



            for (int i = 1; i <= 5; i++)
            {
                Saloon saloon = new Saloon();
                saloon.SaloonNo = i;
                context.Saloons.Add(saloon);
            }
            context.SaveChanges();

            for (int i = 1; i <= 5; i++)
            {
                for (char j = 'A'; j < 'I'; j++)
                {
                    for (int k = 1; k <= 14; k++)
                    {
                        Seat seat = new Seat();
                        seat.SeatActive = false;
                        seat.SaloonID   = i;
                        seat.SessionID  = i;
                        seat.Character  = Convert.ToString(j);
                        seat.Number     = k;
                        context.Seats.Add(seat);
                    }
                }
            }
            context.SaveChanges();


            for (int l = 1; l <= 5; l++)
            {
                MovieSessionSaloon mss = new MovieSessionSaloon();
                mss.MovieID   = l;
                mss.SessionID = l;
                mss.SaloonID  = l;
                context.MovieSessionSaloons.Add(mss);
            }
            context.SaveChanges();
        }
Ejemplo n.º 27
0
        protected override void Seed(MyContext context)
        {
            List <AppUser>  olusturulanKullanicilar = new List <AppUser>();
            List <Category> olusturulanKategoriler  = new List <Category>();
            List <Feature>  olusturulanOzellikler   = new List <Feature>();
            List <Product>  olusturulanUrunler      = new List <Product>();


            #region
            //for (int i = 0; i < 10; i++)
            //{
            //    AppUser ap = new AppUser();
            //    ap.UserName = new Internet("tr").UserName();
            //    ap.Password = new Internet("tr").Password();
            //    ap.Email = new Internet("tr").Email();
            //    context.AppUsers.Add(ap);

            //    AppUserDetail apd = new AppUserDetail();
            //    apd.ID = ap.ID;
            //    apd.FirstName = new Name("tr").FirstName();
            //    apd.LastName = new Name("tr").LastName();
            //    apd.Address = new Address("tr").Locale;
            //    context.AppUserDetails.Add(apd);
            //    context.SaveChanges();


            //}
            #endregion
            for (int i = 0; i < 10; i++)
            {
                AppUser ap = new AppUser();
                ap.UserName = new Internet("tr").UserName();
                ap.Password = DantexCrypt.Crypt(new Internet("tr").Password());
                ap.Email    = new Internet("tr").Email();

                if (olusturulanKullanicilar.Any(x => x.UserName == ap.UserName) == true)
                {
                    i -= 1;
                    continue;
                }
                else
                {
                    olusturulanKullanicilar.Add(ap);
                    context.AppUsers.Add(ap);
                    context.SaveChanges();
                }
            }

            for (int i = 1; i < 11; i++)
            {
                AppUserDetail apd = new AppUserDetail();

                apd.ID        = i; //Birebir ilişkisi oldugundan dolayı id'leri bu sekilde verdik..
                apd.FirstName = new Name("tr").FirstName();
                apd.LastName  = new Name("tr").LastName();
                apd.Address   = new Address("tr").Locale;

                context.AppUserDetails.Add(apd);
                context.SaveChanges();
            }

            #region VeriCekme1

            //Random rnd = new Random();
            //List<Category> cat = new List<Category>();
            //for (int i = 0; i < 5; i++)
            //{
            //    Category c = new Category();

            //    c.CategoryName = new Commerce("tr").Categories(1)[0];
            //    c.Description = new Lorem("tr").Sentence(100);
            //    context.Categories.Add(c);
            //    context.SaveChanges();
            //    cat.Add(c);


            //    for (int x = 0; x < 10; x++)
            //    {
            //        Product p = new Product();

            //        p.ProductName = new Commerce("tr").ProductName();
            //        p.UnitPrice = Convert.ToDecimal(new Commerce("tr").Price());
            //        p.UnitsInStock = rnd.Next(5, 500);
            //        p.ImagePath = new Images().Nightlife();
            //        p.Categories = cat;

            //        context.Products.Add(p);

            //        context.SaveChanges();



            //    }
            //    //cat = null; tek kategori gelsi n diye.

            //}
            #endregion
            #region VeriGetirme1
            //Random rnd = new Random();
            //List<Category> cat = new List<Category>();
            //for (int i = 0; i < 5; i++)
            //{
            //    Category c = new Category();

            //    c.CategoryName = new Commerce("tr").Categories(1)[0];
            //    c.Description = new Lorem("tr").Sentence(100);
            //    context.Categories.Add(c);
            //    context.SaveChanges();
            //    cat.Add(c);


            //    for (int x = 0; x < 10; x++)
            //    {
            //        Product p = new Product();

            //        p.ProductName = new Commerce("tr").ProductName();
            //        p.UnitPrice = Convert.ToDecimal(new Commerce("tr").Price());
            //        p.UnitsInStock = rnd.Next(5, 500);
            //        p.ImagePath = new Images().Nightlife();
            //        p.Categories = cat;

            //        context.Products.Add(p);

            //        context.SaveChanges();



            //    }
            //    //cat = null; tek kategori gelsi n diye.

            //}
            #endregion

            Random rnd = new Random();


            for (int i = 0; i < 15; i++)
            {
                Category c = new Category();

                c.CategoryName = new Commerce("tr").Categories(1)[0];
                c.Description  = new Lorem("tr").Sentence(20);

                if (olusturulanKategoriler.Any(x => x.CategoryName == c.CategoryName) == true)
                {
                    i -= 1;
                    continue;
                }
                else
                {
                    olusturulanKategoriler.Add(c);
                    context.Categories.Add(c);
                    context.SaveChanges();
                }



                for (int j = 0; j < 20; j++)
                {
                    Product p = new Product();

                    p.ProductName  = new Commerce("tr").ProductName();
                    p.UnitPrice    = Convert.ToDecimal(new Commerce("tr").Price());
                    p.UnitsInStock = rnd.Next(5, 500);
                    p.ImagePath    = new Images().Nightlife();

                    if (olusturulanUrunler.Any(x => x.ProductName == p.ProductName) == true)
                    {
                        i -= 1;
                        continue;
                    }
                    else
                    {
                        olusturulanUrunler.Add(p);
                        context.Products.Add(p);
                        context.SaveChanges();
                    }


                    ProductCategory pc = new ProductCategory();
                    pc.ProductID  = p.ID;
                    pc.CategoryID = c.ID;
                    context.ProductCategories.Add(pc);
                    context.SaveChanges();

                    if (i == 2)
                    {
                        ProductCategory pc2 = new ProductCategory();
                        pc2.ProductID  = p.ID;
                        pc2.CategoryID = c.ID - 1;
                        context.ProductCategories.Add(pc2);
                    }
                    context.SaveChanges();

                    for (int k = 0; k < 1; k++)
                    {
                        Feature f = new Feature();
                        f.FeatureName = new Commerce("tr").ProductMaterial();
                        f.Description = new Lorem("tr").Sentence(3);

                        if (olusturulanOzellikler.Any(x => x.FeatureName == f.FeatureName) == true)
                        {
                            i -= 1;
                            continue;
                        }
                        else
                        {
                            olusturulanOzellikler.Add(f);
                            context.Features.Add(f);
                            context.SaveChanges();
                        }


                        ProductFeature pf = new ProductFeature();
                        pf.ProductID = p.ID;
                        pf.FeatureID = f.ID;
                        pf.Value     = new Commerce("tr").Color();
                        context.ProductFeatures.Add(pf);
                        context.SaveChanges();
                    }
                }
            }       //Category eklendi.
                    //Product Eklendi.
                    // feature ve value eklendi
        }
 public override void Add(AppUser item)
 {
     item.Password = DantexCrypt.Crypt(item.Password);
     base.Add(item);
 }