예제 #1
0
        public string Login(LoginModel loginModel)
        {
            SetSessionVariable("UserId", "");
            SetSessionVariable("CoreId", "");

            if (loginModel != null)
            {
                if (ModelState.IsValid)
                {
                    if (RemoteProcedureCallClass
                        .GetUserChannel()
                        .IsRegisteredUser(loginModel.Nickname, loginModel.PasswordHash))
                    {
                        FormsAuthentication.SetAuthCookie(loginModel.Nickname, true);
                        return(true.ToJson());
                    }
                    else
                    {
                        ModelState.AddModelError("", "error: user is not registered!");
                        return("");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "error: model not valid!");
                    return("");
                }
            }
            return("");
        }
예제 #2
0
        public string AllUsersInfo()
        {
            var channel      = RemoteProcedureCallClass.GetUserChannel();
            var allUsersJson = channel.GetAllUsersInfo();

            return(allUsersJson);
        }
예제 #3
0
        public string UsersFollowingsInfo()
        {
            int    userId;
            string userIdString = GetSessionVariable("UserId");

            if (System.Int32.TryParse(userIdString, out userId))
            {
                var channel             = RemoteProcedureCallClass.GetUserChannel();
                var followingsUsersJson = channel.GetUsersFollowingsInfo(userId);
                return(followingsUsersJson);
            }
            else
            {
                return("");
            }
        }
예제 #4
0
        public string Registration(RegistrationModel model)
        {
            SetSessionVariable("UserId", "");
            SetSessionVariable("CoreId", "");

            if (model != null)
            {
                if (ModelState.IsValid)
                {
                    if (!RemoteProcedureCallClass
                        .GetUserChannel()
                        .IsRegisteredUser(model.Nickname, model.PasswordHash))
                    {
                        if (RemoteProcedureCallClass
                            .GetUserChannel()
                            .RegisterUserToTable(model.FirstName,
                                                 model.SecondName, model.PasswordHash,
                                                 model.Nickname, model.Email))
                        {
                            FormsAuthentication.SetAuthCookie(model.Nickname, true);
                            return(model.ToJson());
                        }
                        return("");
                    }
                    else
                    {
                        return("");
                    }
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
예제 #5
0
        public string GetAccountData()
        {
            int userId = RemoteProcedureCallClass.GetUserChannel()
                         .GetUserIdByNickname(User.Identity.Name);

            var core = RemoteProcedureCallClass.GetGameChannel()
                       .GetCoreByUserId(userId).FromJson <SessionCoresTable>();

            SetSessionVariable("UserId", userId.ToString());
            if (core != null)
            {
                if (core.SessionCoreId != 0)
                {
                    SetSessionVariable("CoreId", core.SessionCoreId.ToString());
                }
            }

            AccountData result = new AccountData();

            result.UserId   = userId;
            result.CoreId   = (core != null) ? core.SessionCoreId : 0;
            result.Nickname = User.Identity.Name;
            return(result.ToJson());
        }
예제 #6
0
 public void RemoveUserFromFriends(TwoUsers users)
 {
     RemoteProcedureCallClass
     .GetUserChannel()
     .RemoveUserFromFriends(users.ToJson());
 }
예제 #7
0
 public void AddUserToFriends(TwoUsers users)
 {
     RemoteProcedureCallClass
     .GetUserChannel()
     .AddUserToFriends(users.ToJson());
 }