// GET: Admin/Accounts public async Task <IActionResult> Index(string typeAccount, string searchString) { IQueryable <string> ListTypeAccountQuery = from m in _context.account orderby m.TypeA.Name select m.TypeA.Name; var account = from m in _context.account select m; if (!String.IsNullOrEmpty(searchString)) { account = account.Where(s => s.Name.Contains(searchString)); } if (!string.IsNullOrEmpty(typeAccount)) { account = account.Where(x => x.Name == typeAccount); } var listTypeAccountVM = new SearchAccount { ListAccount = new SelectList(await ListTypeAccountQuery.Distinct().ToListAsync()), Accounts = await account.ToListAsync() }; var dPContext = _context.account.Include(s => s.TypeA.Id); return(View(listTypeAccountVM)); }
public SearchAccount GetDatasFriend(int friendId) { Account friend = _context.Accounts.Find(friendId); if (friend != null) { SearchAccount searchItem = new SearchAccount(); //result model searchItem.Id = friend.Id; searchItem.Friendship = FriendshipStatus.Accepted; searchItem.Label = friend.Fullname; searchItem.Img = friend.ProfileImg; searchItem.Email = friend.Email; searchItem.Phone = friend.Phone; searchItem.Birthday = friend.Birthday; searchItem.Address = friend.Address; searchItem.Website = friend.Website; searchItem.StatusText = friend.StatusText; AccountSocialLink accountSocials = _context.AccountSocialLinks.FirstOrDefault(a => a.AccountId == friendId); searchItem.Facebook = accountSocials.Facebook; searchItem.Twitter = accountSocials.Twitter; searchItem.Instagram = accountSocials.Instagram; searchItem.Linkedin = accountSocials.Linkedin; return(searchItem); } return(null); }
IEnumerator PreloadAccountImages(string key) { Iloading search = new SearchAccount(); Debug.Log("searching..."); yield return(StartCoroutine(PreloadingManager.instance.LoadingProcess(key, search))); if (!search.isContainErrors()) { Debug.Log("Starting load account data"); Iloading type = new Download_FindAccount(); yield return(StartCoroutine(PreloadingManager.instance.LoadingProcess(key, type))); DataSave.SavePostsInfo(type.GetPosts()); yield return(new WaitForSeconds(1)); GameControllerScr.loadGame = false; SceneManager.LoadScene("Game"); } else { Debug.Log("Account not found"); } }
public async Task <ActionResult <List <AccountDto> > > SearchAccount([FromQuery] SearchAccount query) { try { if (query == null) { return(BadRequest("Query cannot be empty")); } var accounts = await _accountService.SearchAccount(query); return(Ok(accounts)); } catch (Exception e) { throw e; } }
public ICollection <SearchAccount> SearchAccounts(int currentUserId, string term) { //final search results List <SearchAccount> results = new List <SearchAccount>(); ICollection <int> accountIdList = _context.Accounts.Where(a => a.Fullname.Contains(term)) .OrderBy(a => a.Name) .Select(a => a.Id) .ToList(); foreach (var itemId in accountIdList) { if (currentUserId != itemId) //don't show current user 2x { if (_friendsRepository.IsFriends(currentUserId, itemId)) //friends { SearchAccount searchItem = _accountDetailRepository.GetDatasFriend(itemId); if (searchItem != null) { results.Add(searchItem); } } else //not friends { SearchAccount searchItem = _accountDetailRepository.GetDatasPublic(currentUserId, itemId); if (searchItem != null) { results.Add(searchItem); } } } else //search own profile { SearchAccount searchItem = _accountDetailRepository.GetDatasOwn(itemId); if (searchItem != null) { results.Add(searchItem); } } } return(results); }
public ICollection <SearchAccount> SearchByName(string term) { List <SearchAccount> results = new List <SearchAccount>(); ICollection <Account> accounts = _context.Accounts.Where(a => a.Name.Contains(term) || a.Surname.Contains(term)) //.Select(a => a.Name + " " + a.Surname) .ToList(); foreach (var item in accounts) { SearchAccount searchItem = new SearchAccount(); //searchItem.Label = item.Name + " " + item.Surname; searchItem.Id = item.Id; searchItem.Img = item.ProfileImg; results.Add(searchItem); } return(results); }
public ICollection <SearchAccount> SearchFriendsAccounts(int currentUserId, string term) { //final search results List <SearchAccount> results = new List <SearchAccount>(); ICollection <Account> friendslist = _friendsRepository.GetAllFriends(currentUserId); foreach (var item in friendslist) { if (item.Fullname.ToLower().Contains(term.ToLower())) { if (currentUserId != item.Id) //don't show current user 2x { SearchAccount searchItem = _accountDetailRepository.GetDatasFriend(item.Id); if (searchItem != null) { results.Add(searchItem); } } } } return(results); }
public async Task <List <Domain.Account> > SearchAccount(SearchAccount request) { using (SqlConnection con = new SqlConnection(connectionStr)) { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "SearchAccountStoreProcedure"; cmd.CommandType = System.Data.CommandType.StoredProcedure; if (!string.IsNullOrEmpty(request.FirstName)) { SqlParameter param = new SqlParameter("@FirstName", request.FirstName); cmd.Parameters.Add(param); } if (!string.IsNullOrEmpty(request.LastName)) { SqlParameter param = new SqlParameter("@LastName", request.LastName); cmd.Parameters.Add(param); } if (!string.IsNullOrEmpty(request.Username)) { SqlParameter param = new SqlParameter("@Username", request.Username); cmd.Parameters.Add(param); } if (request.Role != 0 && request.Role != null) { SqlParameter param = new SqlParameter("@Role", request.Role); cmd.Parameters.Add(param); } con.Open(); var dataReader = await cmd.ExecuteReaderAsync(); var accounts = new List <Domain.Account>(); if (dataReader.HasRows) { while (dataReader.Read()) { var pom = new Domain.Account() { FirstName = dataReader["FirstName"].ToString(), LastName = dataReader["LastName"].ToString(), Password = dataReader["Password"].ToString(), Username = dataReader["Username"].ToString(), Id = int.Parse(dataReader["Id"].ToString()), Role = int.Parse(dataReader["Role"].ToString()), PhoneNumber = dataReader["PhoneNumber"].ToString(), Address = dataReader["Address"].ToString() }; accounts.Add(pom); } } dataReader.Close(); con.Close(); return(accounts); } }
public SearchAccount GetDatasPublic(int currentAccountId, int accountId) { Account account = _context.Accounts.Find(accountId); AccountPrivacy accountPrivacy = _context.AccountPrivacies.FirstOrDefault(p => p.AccountId == account.Id); if (accountPrivacy != null) { SearchAccount searchItem = new SearchAccount(); //id searchItem.Id = account.Id; //fullname searchItem.Label = account.Fullname; //friendship //FriendshipStatus friendshipStatus = _friendsRepository.GetFriendshipStatus(currentAccountId, accountId); Friend friendship = _friendsRepository.GetFriendship(currentAccountId, accountId); if (friendship != null) { if (friendship.StatusCode != FriendshipStatus.Error) { searchItem.Friendship = friendship.StatusCode; } if (friendship.FromUserId == currentAccountId) { searchItem.IsFriendRequestSender = true; } } else { //static for if error ocoured searchItem.Friendship = FriendshipStatus.NotFriend; } //email searchItem.Email = account.Email; // static public //address if (accountPrivacy.Address == false) { searchItem.Address = null; } else { searchItem.Address = account.Address; } //website if (accountPrivacy.Website == false) { searchItem.Website = null; } else { searchItem.Website = account.Website; } //birthday if (accountPrivacy.Birthday == false) { searchItem.Birthday = null; } else { searchItem.Birthday = account.Birthday; } //phone if (accountPrivacy.Phone == false) { searchItem.Phone = null; } else { searchItem.Phone = account.Phone; } //profile img if (accountPrivacy.ProfileImg == false) { searchItem.Img = null; } else { searchItem.Img = account.ProfileImg; } //status text if (accountPrivacy.StatusText == false) { searchItem.StatusText = null; } else { searchItem.StatusText = account.StatusText; } //social links if (accountPrivacy.SocialLink == false) { searchItem.Facebook = null; searchItem.Twitter = null; searchItem.Instagram = null; searchItem.Linkedin = null; } else { AccountSocialLink accountSocials = _context.AccountSocialLinks.FirstOrDefault(a => a.AccountId == accountId); searchItem.Facebook = accountSocials.Facebook; searchItem.Twitter = accountSocials.Twitter; searchItem.Instagram = accountSocials.Instagram; searchItem.Linkedin = accountSocials.Linkedin; } //if (accountPrivacy.AcceptAllMessages == false) //PROBLEM!!! //{ // //} return(searchItem); } return(null); }
public async Task <List <AccountDto> > SearchAccount(SearchAccount query) { var result = await _unitOfWork.Accounts.SearchAccount(query); return(_mapper.Map <List <AccountDto> >(result)); }