private KeyValuePair <bool, string> TryLogin()
        {
            string eUserName = SecurityModel.Encrypt(this.username);
            string ePassword = SecurityModel.Encrypt(this.password);
            KeyValuePair <bool, string> result;

            var temp = _context.Client.Where(x =>
                                             x.uname.Equals(eUserName) &&
                                             x.upass.Equals(ePassword)).FirstOrDefault();

            if (temp == null)
            {
                result = new KeyValuePair <bool, string>(false, "Kullanıcı bulunamadı!!!");
            }
            else if (temp != null && !temp.is_active)
            {
                result = new KeyValuePair <bool, string>(false, "Kullanıcı aktif değil!!!");
            }
            else if (temp != null && temp.is_delete)
            {
                result = new KeyValuePair <bool, string>(false, "Kullanıcı silinmiş!!!");
            }
            else
            {
                this.clientId = temp.id;
                result        = new KeyValuePair <bool, string>(true, "Giriş başarılı...");
            }

            return(result);
        }
示例#2
0
        public IActionResult Signin(SignInModel model, IFormFile file)
        {
            string eUsername = SecurityModel.Encrypt(model.Uname);
            string ePassword = SecurityModel.Encrypt(model.Upass);
            string seoUrl    = Tools.toSlug(model.Uname);
            string aCode     = Tools.generateActivationCode();
            string imageUrl  = null;

            if (file != null && file.Length > 0)
            {
                try
                {
                    string newFileName = seoUrl + DateTime.Now.ToString("_ddMMyyyy_HHmmss") + "." + file.FileName.Split('.').LastOrDefault();

                    var originalDirectory = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\profileImages", newFileName);

                    using (var stream = new FileStream(originalDirectory, FileMode.Create))
                    {
                        file.CopyTo(stream);
                    }
                    imageUrl = "/img/profileImages/" + newFileName;
                }
                catch (Exception ex)
                {
                }
            }
            Clients client = new Clients()
            {
                name            = model.Name,
                desc            = model.Desc,
                is_active       = false,
                is_delete       = false,
                is_corparate    = model.Is_corparate,
                tcno            = model.Tcno,
                uname           = eUsername,
                upass           = ePassword,
                c_date          = DateTime.Now,
                seo_url         = seoUrl,
                activation_code = aCode,
                image_url       = imageUrl,
                email           = model.Email
            };

            _context.Add(client);
            _context.SaveChanges();
            string localHost     = _httpContextAccessor.HttpContext.Request.Host.Value;
            string aCodeMailBody = "<a href ='http://" + localHost +
                                   "/musteri/activateclient/?activation_code=" + aCode +
                                   "&username="******"'>Aktive Edin</a>";

            Tools.sendMail(model.Email, "Aktivasyon Bilgisi", aCodeMailBody);
            return(View(model));
        }