Beispiel #1
0
        public JsonResult Login(User p, string RememberMe, string SirketKodu = "")
        {
            _result = new Result();
            var fn = new Functions();

            using (var db = new WMSEntities())
            {
                using (var person = new Persons())
                    try
                    {
                        if (string.IsNullOrEmpty(p.Kod) || string.IsNullOrEmpty(p.Sifre))
                        {
                        }
                        else
                        {
                            _result = person.Login(p, fn.GetIPAddress());
                            if (_result.Id > 0)
                            {
                                var sirket = SirketKodu == "" ? db.GetSirkets().FirstOrDefault() : db.GetSirkets().FirstOrDefault(m => m.Kod == SirketKodu);
                                Authentication.CreateAuth((User)_result.Data, RememberMe == "1", sirket);
                            }
                            else
                            {
                                db.LogLogins(p.Kod, fn.GetIPAddress(), false, _result.Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        var inner = "";
                        if (ex.InnerException != null)
                        {
                            inner = ex.InnerException?.Message;
                            if (ex.InnerException.InnerException != null)
                            {
                                inner += ": " + ex.InnerException.InnerException.Message;
                            }
                        }

                        db.Logger(p.Kod, "", fn.GetIPAddress(), ex.Message, inner, "Security/Login");
                        db.LogLogins(p.Kod, fn.GetIPAddress(), false, ex.Message);
                        return(null);
                    }
            }

            return(Json(new { data = (_result.Status) }, JsonRequestBehavior.AllowGet));
        }