Пример #1
0
 public int SignIn(string name)
 {
     if (_userId == 0)
     {
         var user = _core.GetUsers().Where(u => u.Name == name).FirstOrDefault();
         if (user == null)
         {
             _core.CreateUser(new ATF.Model.User()
             {
                 CashValue = 0,
                 Name      = name
             });
             user = _core.GetUsers().Where(u => u.Name == name).FirstOrDefault();
         }
         _userId = user.Id;
     }
     return(_userId);
 }
Пример #2
0
        public JsonResult GetUser()
        {
            var   userId = UserContext.Instance.UserId;
            IUser user   = new User()
            {
                CashValue  = 0,
                IsSignedIn = false
            };

            if (userId != 0)
            {
                user            = _core.GetUsers().Where(u => u.Id == userId).FirstOrDefault();
                user.IsSignedIn = true;
            }
            return(Json(user, JsonRequestBehavior.AllowGet));
        }