示例#1
0
        public void resetLoginInfo()
        {
            vrlfgysdbEntities db = new vrlfgysdbEntities();
            int id = GetCurrentUser.GetUser().id;

            FormsAuthentication.SignOut();
            kullanicilar usr = db.kullanicilar.Where(e => e.id == id).FirstOrDefault();

            if (usr != null)
            {
                LoggedUserModel loggedUser = new LoggedUserModel();
                foreach (var property in loggedUser.GetType().GetProperties())
                {
                    try
                    {
                        var response = usr.GetType().GetProperty(property.Name).GetValue(usr, null).ToString();
                        if (response == null && property.PropertyType != typeof(int))
                        {
                            if (response == null)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            PropertyInfo propertyS = loggedUser.GetType().GetProperty(property.Name);
                            if (property.PropertyType == typeof(decimal))
                            {
                                propertyS.SetValue(loggedUser, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                            }
                            else if (property.PropertyType == typeof(int))
                            {
                                if (response == null)
                                {
                                    propertyS.SetValue(loggedUser, Convert.ChangeType(0, property.PropertyType), null);
                                }
                                else
                                {
                                    propertyS.SetValue(loggedUser, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                }
                            }
                            else
                            {
                                propertyS.SetValue(loggedUser, Convert.ChangeType(response, property.PropertyType), null);
                            }
                        }
                    }
                    catch (Exception)
                    { }
                }
                Guid gd = new Guid();
                gd = Guid.NewGuid();
                string            query = "select * from firma_musavir where flag = " + durumlar.aktif.ToString() + " and id = " + loggedUser.firma_id;
                FirmaMusavirModel fmm   = db.Database.SqlQuery <FirmaMusavirModel>(query).FirstOrDefault();
                loggedUser.fm = fmm;
                SetAuthCookie(gd.ToString(), true, loggedUser);
            }
        }
        public JsonResult Index(string username, string password)
        {
            /*var response = Request["g-recaptcha-response"];
             * if (!validateCaptcha.validateC(response))
             * {
             *  return Json(FormReturnTypes.captchaHatasi, JsonRequestBehavior.AllowGet);
             * }*/
            string       sifre = HashWithSha.ComputeHash(password, "SHA512", Encoding.ASCII.GetBytes(password));
            kullanicilar usr   = db.kullanicilar.Where(e => e.username == username && e.password == sifre && e.flag == durumlar.aktif && e.kullanici_turu == KullaniciTurleri.super_admin).FirstOrDefault();

            if (usr != null)
            {
                LoggedUserModel loggedUser = new LoggedUserModel();
                foreach (var property in loggedUser.GetType().GetProperties())
                {
                    try
                    {
                        var response = usr.GetType().GetProperty(property.Name).GetValue(usr, null).ToString();
                        if (response == null && property.PropertyType != typeof(int))
                        {
                            if (response == null)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            PropertyInfo propertyS = loggedUser.GetType().GetProperty(property.Name);
                            if (property.PropertyType == typeof(decimal))
                            {
                                propertyS.SetValue(loggedUser, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                            }
                            else if (property.PropertyType == typeof(int))
                            {
                                if (response == null)
                                {
                                    propertyS.SetValue(loggedUser, Convert.ChangeType(0, property.PropertyType), null);
                                }
                                else
                                {
                                    propertyS.SetValue(loggedUser, Convert.ChangeType(Decimal.Parse(response.Replace('.', ',')), property.PropertyType), null);
                                }
                            }
                            else
                            {
                                propertyS.SetValue(loggedUser, Convert.ChangeType(response, property.PropertyType), null);
                            }
                        }
                    }
                    catch (Exception)
                    { }
                }

                Guid gd = new Guid();
                gd = Guid.NewGuid();

                string            query = "select * from firma_musavir where flag = " + durumlar.aktif.ToString() + " and id = " + loggedUser.firma_id;
                FirmaMusavirModel fmm   = db.Database.SqlQuery <FirmaMusavirModel>(query).FirstOrDefault();
                loggedUser.fm = fmm;

                SetAuthCookie(gd.ToString(), true, loggedUser);
                return(Json(FormReturnTypes.basarili, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(FormReturnTypes.basarisiz, JsonRequestBehavior.AllowGet));
            }
        }