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(""); }
public string AllUsersInfo() { var channel = RemoteProcedureCallClass.GetUserChannel(); var allUsersJson = channel.GetAllUsersInfo(); return(allUsersJson); }
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(""); } }
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(""); } }
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()); }
public void RemoveUserFromFriends(TwoUsers users) { RemoteProcedureCallClass .GetUserChannel() .RemoveUserFromFriends(users.ToJson()); }
public void AddUserToFriends(TwoUsers users) { RemoteProcedureCallClass .GetUserChannel() .AddUserToFriends(users.ToJson()); }