public async Task <IEnumerable <SavedIdsToSend> > GetSavedIdsBySavedFilterId(int savedFilterId) { var savedIds = _dataMarketDbContext.SavedIds .Where(f => f.SavedFilterId == savedFilterId).ToList(); List <SavedIdsToSend> myList = new List <SavedIdsToSend>(); foreach (var val in savedIds) { SavedIdsToSend objSevedId = new SavedIdsToSend(); var group = await _groupRepository.GetGroupByGroupId(val.GroupId); var filter = await _filterRepository.GetById(val.FilterId); var filterValue = await _filterValueRepository.GetFilterValuesByFilterValueId(val.FilterValueId); objSevedId.GroupName = group.DisplayName; objSevedId.FilterName = filter.DisplayName; objSevedId.FilterValueName = filterValue.DisplayName; objSevedId.FilterId = val.FilterId; objSevedId.FilterValueId = val.FilterValueId; objSevedId.GroupId = val.GroupId; objSevedId.SavedId = val.SavedId; objSevedId.SavedFilterId = val.SavedFilterId; objSevedId.Count = val.Count; myList.Add(objSevedId); } return(myList); }
public async Task <IEnumerable <ListInProgressItem> > GetListInProgress(int userId) { var tableName = string.Format("ListInProgress_{0}", userId); var connectionString = ConfigurationManager.AppSettings["ConnectionString"]; var connetionStringDMC = ConfigurationManager.AppSettings["ConnectionStringDMC"]; var connection = new SqlConnection(connectionString); var connectionDMC = new SqlConnection(connetionStringDMC); var queryString = string.Format("SELECT * FROM {0}", tableName); var command = new SqlCommand(queryString, connection); connection.Open(); connectionDMC.Open(); var dataReader = await command.ExecuteReaderAsync(); var listInProgress = new List <ListInProgressItem>(); while (dataReader.Read()) { var listItemId = int.Parse(dataReader["ListItemId"].ToString()); var groupId = int.Parse(dataReader["GroupId"].ToString()); var filterId = int.Parse(dataReader["FilterId"].ToString()); var filterValueId = int.Parse(dataReader["FilterValueId"].ToString()); var group = await _groupRepository.GetGroupByGroupId(groupId); var filter = await _filterRepository.GetById(filterId); var filterValue = await _filterValueRepository.GetFilterValuesByFilterValueId(filterValueId); var listItem = new ListInProgressItem { ListItemId = listItemId, GroupId = groupId, FilterId = filterId, FilterValueId = filterValueId, GroupName = group.GroupName, FilterName = filter.FilterName, FilterValueName = filterValue.FilterValueName }; listInProgress.Add(listItem); } connection.Close(); connectionDMC.Close(); return(listInProgress); }