Esempio n. 1
0
        public ActionResult Register(RegisterViewModal model)
        {
            if (ModelState.IsValid)
            {
                //if (model.Username == "aaa")
                //{
                //    ModelState.AddModelError("", "Kullanıcı Adı kullanılıyor");

                //}

                //if (model.Email == "*****@*****.**")
                //{
                //    ModelState.AddModelError("", "Eposta adresi kullanılıyor");

                //}

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

                //}

                return(RedirectToAction("RegisterOk"));
            }

            //kullanıcı username kontrolü
            //kullanıcı eposta kontrolü
            //kayıt işlemi
            //aktivasyon epostası gönderimi

            return(View(model));
        }
Esempio n. 2
0
        public async Task <IActionResult> Register(RegisterViewModal model)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var user = new ApplicationUser
            {
                UserName = model.Email,
                Email    = model.Email,
                City     = model.City
            };
            var result = await UserManager.CreateAsync(user, model.Password);

            if (result.Succeeded)
            {
                if (SignInManager.IsSignedIn(User) && User.IsInRole("Admin"))
                {
                    return(RedirectToAction("ListUsers", "Adminstration"));
                }

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

                return(RedirectToAction("Index", "Home"));
            }
            foreach (var error in result.Errors)
            {
                ModelState.AddModelError(string.Empty, error.Description);
            }
            return(View());
        }
Esempio n. 3
0
        public ActionResult MailOkey(RegisterViewModal data)
        {
            try
            {
                SmtpClient smtpclient            = new SmtpClient();
                System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
                smtpclient.Port      = 587;
                smtpclient.EnableSsl = true;
                const string username    = "******";
                const string password    = "******";
                MailAddress  fromaddress = new MailAddress("*****@*****.**");
                smtpclient.Host = "smtp.gmail.com"; //mail.yesilkasaba.com
                mail.To.Add("*****@*****.**");
                mail.To.Add("*****@*****.**");

                mail.From = fromaddress;

                mail.Subject = ("Yeni Kayıt");

                mail.IsBodyHtml = true;

                string icerik = "";


                icerik += @"<img   align='center' border='0' class='center autowidth' 
                src = 'http://www.sayazilim.com/wp-content/uploads/2018/02/SA-YAZILIM-LOGO.png'
                style = 'text-decoration: none; -ms-interpolation-mode: bicubic; height: auto; border: 0; text-align:center; width: 10%; max-width: 250px; display: block;' /> ";
                icerik += "<br /><br /><b><font color=#b03060>Firma Bilgileri</font></b><br />";
                icerik += "<br /><b>Firma Adı : </b>" + data.FirmaIsmi;
                icerik += "<br /><b>Firma Mail Adresi : </b>" + data.Email;
                icerik += "<br /><b>Firma Tel : </b>" + data.FirmaTel;
                icerik += "<br /><b>Açıklama : </b>" + data.Aciklama;



                ContentType mimeType = new System.Net.Mime.ContentType("text/html");


                AlternateView alternate = AlternateView.CreateAlternateViewFromString(icerik, mimeType);
                mail.AlternateViews.Add(alternate);
                smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpclient.Credentials    = new System.Net.NetworkCredential(username, password);
                smtpclient.EnableSsl      = true;

                ViewBag.message = "Kaydınız Başarıyla Oluşturulmuştur.";

                smtpclient.Send(mail);
                return(Json(new { success = true, Message = "Mail Gönderildi" }));
            }
            catch (Exception E1)
            {
                System.IO.File.WriteAllText(Path.Combine(@"C: \Users\Alperen\AppData\Local\Sayazilim", "sonuc.xml"), E1.ToString());
                return(Json(new { success = false, Message = "Mail Gönderilemedi" }));
            }
        }
        public BusinessResult <EvernoteUser> RegisterUser(RegisterViewModal data)
        {
            EvernoteUser user = Find(x => x.UserName == data.UserName || x.Email == data.Email);
            BusinessResult <EvernoteUser> res = new BusinessResult <EvernoteUser>();

            if (user != null)
            {
                if (user.UserName == data.UserName)
                {
                    res.AddError(ErrorMessageCode.UsernameAlreadyExists, "Kullanıcı Adı Kayıtlı");
                }

                if (user.Email == data.Email)
                {
                    res.AddError(ErrorMessageCode.EmailAlreadyExists, "Email Adres Kayıtlı");
                }
            }
            else
            {
                int dbResult = base.Insert(new EvernoteUser()
                {
                    UserName             = data.UserName,
                    Email                = data.Email,
                    Password             = data.Password,
                    ProfileImageFileName = "user_default.png",
                    ActivateGuid         = Guid.NewGuid(),
                    IsActive             = false,
                    IsAdmin              = false,
                });
                if (dbResult > 0)
                {
                    res.Result = Find(x => x.Email == data.Email && x.UserName == data.UserName);
                    string siteUri     = ConfigHelper.Get <string>("SiteRootUri");
                    string activateUri = $"{siteUri}/Home/UserActivate/{res.Result.ActivateGuid}";
                    string body        = ($"Merhaba {res.Result.UserName};<br><br>Hesabınızı aktifleştirmek için <a href='{activateUri}' target='_blank'>tıklayınız</a>.");
                    MailHelper.SendMail(body, res.Result.Email, "MyEvernote Hesap Aktifleştirme");
                }
            }
            return(res);
        }
        public BusinessLayerResult <EvernoteUser> RegisterUser(RegisterViewModal data)
        {
            //kullanıcı username kontrolü
            //kullanıcı eposta kontrolü
            //kayıt işlemi
            //aktivasyon epostası gönderimi

            EvernoteUser user = repo_user.Find(x => x.Username == data.Username || x.Email == data.Email);
            BusinessLayerResult <EvernoteUser> layerResult = new BusinessLayerResult <EvernoteUser>();

            if (user != null)
            {
                if (user.Username == data.Username)
                {
                    layerResult.Errors.Add("Kullanıcı Adı kayıtlı");
                }

                if (user.Email == data.Email)
                {
                    layerResult.Errors.Add("Eposta kayıtlı");
                }
            }
            else
            {
                int dbResult = repo_user.Insert(new EvernoteUser()
                {
                    Username = data.Username,
                    Email    = data.Email,
                    Password = data.Password
                });
                if (dbResult > 1)
                {
                    layerResult.Result = repo_user.Find(x => x.Email)
                }
            }

            return(layerResult);
        }
Esempio n. 6
0
        public ActionResult Register(RegisterViewModal modal)
        {
            if (ModelState.IsValid)
            {
                BusinessResult <EvernoteUser> res = evernoteUserManager.RegisterUser(modal);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));

                    return(View(modal));
                }
                OKViewModal notifyObj = new OKViewModal()
                {
                    Title          = "Kayıt Başarılı",
                    RedirectingUrl = "/Home/Login"
                };
                notifyObj.Items.Add("Please, Your Email sending Activation Mail must access.");

                return(View("Ok", notifyObj));
            }
            return(View(modal));
        }
Esempio n. 7
0
        public ActionResult Register(RegisterViewModal rg)
        {
            sayazilimEntities db = new sayazilimEntities();

            try
            {
                var firmalarlist = db.Firmalar.Where(x => x.FirmaEMail == rg.Email).ToList();

                if (firmalarlist.Count == 0)
                {
                    Firmalar fr = new Firmalar();

                    fr.FirmaAdi = rg.FirmaIsmi;
                    string sifre = rg.Password;
                    fr.FirmaEMail = rg.Email;
                    fr.FirmaTel   = rg.FirmaTel;
                    var firmalist = db.Firmalar.OrderByDescending(x => x.ID).FirstOrDefault();
                    if (firmalist != null)
                    {
                        int i = Convert.ToInt32(firmalist.FirmaID + 1);
                        fr.FirmaID = i;
                    }
                    else
                    {
                        fr.FirmaID = 2;
                    }

                    DateTime kayittarih = DateTime.Now;

                    kayittarih    = kayittarih.AddDays(15);
                    fr.KayitTarih = kayittarih;


                    Personel pr = new Personel();
                    pr.Adi           = "Admin";
                    pr.Soyadi        = "";
                    pr.Pozisyonu     = "Admin";
                    pr.PersonelGrubu = "Admin";
                    pr.FirmaID       = Convert.ToInt16(fr.FirmaID);
                    pr.sCariID       = -1;
                    pr.WebKA         = rg.KullaniciAdi;
                    pr.WebSifre      = GirisKontrol.hash(sifre, true);
                    fr.Demo          = true;
                    db.Personel.Add(pr);
                    db.Firmalar.Add(fr);
                    db.SaveChanges();



                    #region YeniFirmaKontrol
                    int firmaid = Convert.ToInt16(pr.FirmaID);
                    var setting = db.Ayarlar.Where(x => x.FirmaID == firmaid).ToList();
                    if (setting.Count == 0)
                    {
                        DataRow dt = null;
                        using (SqlConnection con = new SqlConnection(AyarMetot.conString))
                        {
                            if (con.State == ConnectionState.Closed)
                            {
                                con.Open();
                            }
                            using (SqlDataAdapter da =
                                       new System.Data.SqlClient.SqlDataAdapter(
                                           "select * from AYARLAR where ID='1'", con))
                            {
                                using (SqlCommandBuilder cb = new SqlCommandBuilder(da))
                                {
                                    DataSet ds = new DataSet();
                                    da.Fill(ds, "AYARLAR");
                                    DataRow[] adf = ds.Tables["AYARLAR"].Select("ID='1'");
                                    if (adf.Length != 0)
                                    {
                                        dt = adf[0];
                                    }
                                }
                            }
                        }
                        using (SqlConnection con = new SqlConnection(AyarMetot.strcon))
                        {
                            if (con.State == ConnectionState.Closed)
                            {
                                con.Open();
                            }
                            using (SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select Top 1 * from AYARLAR where FirmaID=" + firmaid.ToString(), con))
                            {
                                using (SqlCommandBuilder cb = new SqlCommandBuilder(da))
                                {
                                    DataSet ds = new DataSet();
                                    da.Fill(ds, "AYARLAR");
                                    DataRow df = ds.Tables["AYARLAR"].NewRow();
                                    df.ItemArray  = dt.ItemArray.Clone() as object[];
                                    df["FirmaID"] = fr.FirmaID;

                                    df["Version"]             = KODLA.Kapa(rg.Pakettipi, AyarMetot.ilhan_Control);
                                    df["fMail"]               = "";
                                    df["fMailSifre"]          = "";
                                    df["fMailSender"]         = "";
                                    df["SMSUser"]             = "";
                                    df["SMSPass"]             = "";
                                    df["MesajSonu"]           = "";
                                    df["BorcMesajSonu"]       = "";
                                    df["SmsSender"]           = "";
                                    df["EFatGB"]              = "";
                                    df["EFatKA"]              = "";
                                    df["EFatSifre"]           = "";
                                    df["EIrsKA"]              = "";
                                    df["EIrsSF"]              = "";
                                    df["KurumKodu"]           = "";
                                    df["EIrsGB"]              = "";
                                    df["Entegrator"]          = "";
                                    df["PostaSunucu"]         = "";
                                    df["ServisBorclandirsin"] = 1;
                                    string company_code = "SA01" + fr.FirmaID.ToString().PadLeft(3, '0');
                                    df["Company_Code"] = company_code;
                                    ds.Tables["AYARLAR"].Rows.Add(df);
                                    da.Update(ds, "AYARLAR");
                                }
                            }
                        }
                    }
                    var compony = db.COMPANY_DETAIL.Where(x => x.FirmaID == firmaid).ToList();
                    if (compony.Count == 0)
                    {
                        DataRow dt = null;
                        using (SqlConnection con = new SqlConnection(AyarMetot.conString))
                        {
                            if (con.State == ConnectionState.Closed)
                            {
                                con.Open();
                            }
                            using (SqlDataAdapter da =
                                       new System.Data.SqlClient.SqlDataAdapter(
                                           "select * from COMPANY_DETAIL where ID='1'", con))
                            {
                                using (SqlCommandBuilder cb = new SqlCommandBuilder(da))
                                {
                                    DataSet ds = new DataSet();
                                    da.Fill(ds, "COMPANY_DETAIL");
                                    DataRow[] adf = ds.Tables["COMPANY_DETAIL"].Select("ID='1'");
                                    if (adf.Length != 0)
                                    {
                                        dt = adf[0];
                                    }
                                }
                            }
                        }
                        using (SqlConnection con = new SqlConnection(AyarMetot.strcon))
                        {
                            if (con.State == ConnectionState.Closed)
                            {
                                con.Open();
                            }
                            using (SqlDataAdapter da = new System.Data.SqlClient.SqlDataAdapter("select Top 1 * from COMPANY_DETAIL", con))
                            {
                                using (SqlCommandBuilder cb = new SqlCommandBuilder(da))
                                {
                                    DataSet ds = new DataSet();
                                    da.Fill(ds, "COMPANY_DETAIL");
                                    DataRow df = ds.Tables["COMPANY_DETAIL"].NewRow();
                                    df.ItemArray = dt.ItemArray.Clone() as object[];
                                    Firmalar frm = db.Firmalar.Where(x => x.FirmaID == firmaid).FirstOrDefault();
                                    df["FirmaAdi"] = frm.FirmaAdi;
                                    string company_code = "SA01" + fr.FirmaID.ToString().PadLeft(3, '0');
                                    df["Company_Code"] = company_code;
                                    Personel pb = db.Personel.OrderByDescending(x => x.ID).FirstOrDefault();
                                    df["IlgiliKisi"] = (pb.Adi + pb.Soyadi).TrimEnd();
                                    Firmalar dr = db.Firmalar.Where(x => x.FirmaID == firmaid).FirstOrDefault();
                                    df["Telefon"]        = dr.FirmaTel;
                                    df["Faks"]           = "";
                                    df["ePosta"]         = dr.FirmaEMail;
                                    df["WebSite"]        = "";
                                    df["VergiDairesi"]   = "";
                                    df["VergiNo"]        = "";
                                    df["Ulke"]           = "";
                                    df["Sehir"]          = "";
                                    df["PostaKodu"]      = "";
                                    df["Adres"]          = "";
                                    df["TicaretSicilNo"] = "";
                                    df["MersisNo"]       = "";
                                    df["Ilce"]           = "";
                                    df["FirmaID"]        = fr.FirmaID;

                                    ds.Tables["COMPANY_DETAIL"].Rows.Add(df);
                                    da.Update(ds, "COMPANY_DETAIL");
                                }
                            }
                        }
                    }

                    var stk_ktg = db.STK_KATEGORI.Where(x => x.FirmaID == firmaid).ToList();
                    if (stk_ktg.Count == 0)
                    {
                        int i = 7;
                        for (int j = 1; j < i; j++)
                        {
                            STK_KATEGORI stk = new STK_KATEGORI();
                            stk.FirmaID = fr.FirmaID;
                            stk.Name    = "Stok Kategori " + j;
                            string company_code = "SA01" + fr.FirmaID.ToString().PadLeft(3, '0');
                            stk.Company_Code = company_code;
                            db.STK_KATEGORI.Add(stk);
                            db.SaveChanges();
                        }
                    }

                    var special = db.SPECIAL_TECH.Where(x => x.FirmaID == firmaid).ToList();
                    if (special.Count == 0)
                    {
                        int i = 11;
                        for (int j = 1; j < i; j++)
                        {
                            SPECIAL_TECH stk = new SPECIAL_TECH();
                            stk.FirmaID = Convert.ToInt16(fr.FirmaID);
                            stk.Name    = "Özel Alan " + j;
                            string company_code = "SA01" + fr.FirmaID.ToString().PadLeft(3, '0');
                            stk.Company_Code = company_code;
                            db.SPECIAL_TECH.Add(stk);
                            db.SaveChanges();
                        }
                    }


                    var carikategori = db.CARI_KATEGORI.Where(x => x.FirmaID == firmaid).ToList();
                    if (carikategori.Count == 0)
                    {
                        int i = 7;
                        for (int j = 1; j < i; j++)
                        {
                            CARI_KATEGORI stk = new CARI_KATEGORI();
                            stk.FirmaID = firmaid;
                            stk.Name    = "Cari Kategori " + j;
                            string company_code = "SA01" + fr.FirmaID.ToString().PadLeft(3, '0');
                            stk.Company_Code = company_code;
                            db.CARI_KATEGORI.Add(stk);
                            db.SaveChanges();
                        }
                    }
                    var faturaekbilgi = db.INVOICE_OZEL.Where(x => x.FirmaID == firmaid).ToList();
                    if (carikategori.Count == 0)
                    {
                        int i = 9;
                        for (int j = 1; j < i; j++)
                        {
                            INVOICE_OZEL stk = new INVOICE_OZEL();
                            stk.FirmaID         = firmaid;
                            stk.Name            = "Fature Ek Bilgi " + j;
                            stk.EfaturadaGonder = false;
                            string company_code = "SA01" + fr.FirmaID.ToString().PadLeft(3, '0');
                            stk.Company_Code = company_code;
                            db.INVOICE_OZEL.Add(stk);
                            db.SaveChanges();
                        }
                    }


                    #endregion


                    Session["FirmaAdi"] = fr.FirmaAdi;
                    MailOkey(rg);
                    return(RedirectToAction("Login", "Login"));
                }
                else
                {
                    return(View());
                }
            }
            catch (Exception e)
            {
                return(View());
            }
        }