public async Task <UserOverviewModel> GetUserOverview(string username) { UserOverviewModel overview = new UserOverviewModel(); var command = new NpgsqlCommand(); command.CommandText = $"SELECT {savedSearchSelectColumns} FROM {savedSearchTable} WHERE username=@username;"; command.Parameters.AddWithValue("username", username); var savedSearches = new List <SavedSearchModel>(); await db.CommandReaderAsync(command, reader => { int ordinal = 0; var savedSearch = new SavedSearchModel(); savedSearch.Created = reader.GetDateTime(ordinal++); savedSearch.Criteria = JsonConvert.DeserializeObject <SearchCriteria>(reader.GetString(ordinal++)); savedSearch.Username = reader.GetString(ordinal++); savedSearch.ID = reader.GetInt32(ordinal++); savedSearches.Add(savedSearch); }); overview.Username = username; overview.SavedSearches = savedSearches.ToArray(); return(overview); }
public async Task <UserOverviewModel> Overview(string username) { var response = new UserOverviewModel(); try { response = await db.GetUserOverview(username); } catch (Exception e) { await raven.CaptureNetCoreEventAsync(e); } return(response); }
public ActionResult UserAccount(UserOverviewModel model, int?start) { if (model == null) { model = new UserOverviewModel(); } int total; User userInfo = @Utilities.GetCurrentUserInfo(); using (var proxy = new UserProxy()) { foreach (UserRole UserRole in userInfo.UserRoles) { if (UserRole.RoleType == (int)RoleType.UserAdmin) { using (var Organizationproxy = new OrganizationProxy()) { model.SearchResult = proxy.GetUserListByUserAdmin(start, Constants.PageSize, out total, Convert.ToString(model.UserId), (userInfo.Organisation_GUID), Constants.WindowsAuthentication).ToList(); model.Pagers = new Pager((start.HasValue ? start.Value : 0), total, Constants.PageSize); } } else if (UserRole.RoleType == (int)RoleType.SystemAdmin) { model.SearchResult = proxy.GetUserList(start, Constants.PageSize, out total, Convert.ToString(model.UserId), Convert.ToString(model.UserName), Constants.WindowsAuthentication).ToList(); model.Pagers = new Pager((start.HasValue ? start.Value : 0), total, Constants.PageSize); } else if (UserRole.RoleType == (int)RoleType.NormalUser) { model.SearchResult = proxy.GetUserList(start, Constants.PageSize, out total, Convert.ToString(model.UserId), Convert.ToString(userInfo.UserName), Constants.WindowsAuthentication).ToList(); model.Pagers = new Pager((start.HasValue ? start.Value : 0), total, Constants.PageSize); } else if (UserRole.RoleType == (int)RoleType.RigUser) { model.SearchResult = proxy.GetUserList(start, Constants.PageSize, out total, Convert.ToString(model.UserId), Convert.ToString(userInfo.UserName), Constants.WindowsAuthentication).ToList(); model.Pagers = new Pager((start.HasValue ? start.Value : 0), total, Constants.PageSize); } } } return(View(model)); }