Ejemplo n.º 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("");
        }
Ejemplo n.º 2
0
        public string AllUsersInfo()
        {
            var channel      = RemoteProcedureCallClass.GetUserChannel();
            var allUsersJson = channel.GetAllUsersInfo();

            return(allUsersJson);
        }
Ejemplo n.º 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("");
            }
        }
Ejemplo n.º 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("");
            }
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 6
0
 public void RemoveUserFromFriends(TwoUsers users)
 {
     RemoteProcedureCallClass
     .GetUserChannel()
     .RemoveUserFromFriends(users.ToJson());
 }
Ejemplo n.º 7
0
 public void AddUserToFriends(TwoUsers users)
 {
     RemoteProcedureCallClass
     .GetUserChannel()
     .AddUserToFriends(users.ToJson());
 }