Example #1
0
        public void Insert(ChallengeFilterDto challengeFilterDto)
        {
            var invite = _inviteRepository.Find(x =>
                                                x.ChallengeId == challengeFilterDto.Id &&
                                                x.UserId == Guid.Parse("8268c85c-6355-4ebd-b498-0d1a8839e052"))
                         .FirstOrDefault();

            if (invite == null)
            {
                return;
            }

            foreach (var filter in challengeFilterDto.Filters)
            {
                filter.InviteId = invite.Id;
                var tmpIdea = _filterRepository.GetById(filter.Id);
                if (tmpIdea == null)
                {
                    _filterRepository.Add(filter);
                }
                else
                {
                    tmpIdea.Title       = filter.Title;
                    tmpIdea.Description = filter.Description;
                    _filterRepository.Update(tmpIdea);
                }
            }

            var challenge = _challengeRepository.GetById(challengeFilterDto.Id);

            if (challenge.ChallengeState == 3)
            {
                challenge.ChallengeState += 1;
            }
        }
        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);
        }
Example #4
0
 public Filter GetFilter(Guid id)
 {
     return(_filterRepository.GetById(id));
 }
Example #5
0
        public Filter GetFilter(int id)
        {
            var filter = filtersRepository.GetById(id);

            return(filter);
        }