Exemplo n.º 1
0
        private ChallengeSelectionFilterDto InsertSelectionFilter(
            ChallengeSelectionFilterDto challengeSelectionFilterDto)
        {
            foreach (var filter in challengeSelectionFilterDto.Review)
            {
                var reviewFilter = new FilterStatus
                {
                    FilterId = filter.Id,
                    StatusId = Guid.Parse("11f4e235-bbee-4527-a88a-2d239aa91ee6"),
                    UserId   = Guid.Parse("5b7127e5-b581-4a87-bbdb-5312b9ded2cc")
                };
                _filterStatusRepository.Add(reviewFilter);
            }

            foreach (var filter in challengeSelectionFilterDto.Keep)
            {
                var keepFilter = new FilterStatus
                {
                    FilterId = filter.Id,
                    StatusId = Guid.Parse("6b2ac6fa-0895-448b-8016-70b26355b211"),
                    UserId   = Guid.Parse("5b7127e5-b581-4a87-bbdb-5312b9ded2cc")
                };
                _filterStatusRepository.Add(keepFilter);
            }

            foreach (var filter in challengeSelectionFilterDto.Kill)
            {
                var killFilter = new FilterStatus
                {
                    FilterId = filter.Id,
                    StatusId = Guid.Parse("e23a5191-5f41-4c00-b855-d87b14dc9180"),
                    UserId   = Guid.Parse("5b7127e5-b581-4a87-bbdb-5312b9ded2cc")
                };
                _filterStatusRepository.Add(killFilter);
            }

            foreach (var filter in challengeSelectionFilterDto.Multiply)
            {
                var multiplyFilter = new FilterStatus
                {
                    FilterId = filter.Id,
                    StatusId = Guid.Parse("410031b0-0975-4769-88fb-ef742e2f7702"),
                    UserId   = Guid.Parse("5b7127e5-b581-4a87-bbdb-5312b9ded2cc")
                };
                _filterStatusRepository.Add(multiplyFilter);
            }

            var challenge = _challengeRepository.GetById(challengeSelectionFilterDto.ChallengeId);

            if (challenge.ChallengeState == 5)
            {
                challenge.ChallengeState += 1;
            }
            return(challengeSelectionFilterDto);
        }
Exemplo n.º 2
0
 public ChallengeSelectionFilterDto GetSelectionFilter(ChallengeSelectionFilterDto challengeSelectionFilterDto)
 {
     if (challengeSelectionFilterDto.Kill == null &&
         challengeSelectionFilterDto.Keep == null &&
         challengeSelectionFilterDto.Review == null &&
         challengeSelectionFilterDto.Multiply == null)
     {
         return(GetSelectionFilterList(challengeSelectionFilterDto));
     }
     return(InsertSelectionFilter(challengeSelectionFilterDto));
 }
 public IActionResult Post([FromBody] ChallengeSelectionFilterDto challengeSelectionFilterDto)
 {
     try
     {
         challengeSelectionFilterDto = _filterStatusService.UpdateRankFilterStatus(challengeSelectionFilterDto);
         _unitOfWork.Commit();
         return(Ok(challengeSelectionFilterDto));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Exemplo n.º 4
0
        public ChallengeSelectionFilterDto GetSelectionFilter(Guid challengeId)
        {
            var filterStatuses = _filterStatusRepository.GetSelectionFilter(null, challengeId);
            var keep           = filterStatuses.OrderBy(x => x.Rank).Where(x => x.Status.Title.ToLower() == "keep")
                                 .Select(x => x.Filter).ToList();

            var challengeSelectionFilterDto = new ChallengeSelectionFilterDto
            {
                ChallengeId = challengeId,
                Keep        = keep
            };

            return(challengeSelectionFilterDto);
        }
Exemplo n.º 5
0
        public ChallengeSelectionFilterDto UpdateRankFilterStatus(
            ChallengeSelectionFilterDto challengeSelectionFilterDto)
        {
            for (var index = 0; index < challengeSelectionFilterDto.Keep.Count; index++)
            {
                var filter       = challengeSelectionFilterDto.Keep[index];
                var filterStatus = _filterStatusRepository.GetFilterStatus(filter.Id);
                filterStatus.Rank = index + 1;
                _filterStatusRepository.Update(filterStatus);
            }

            var challenge = _challengeRepository.GetById(challengeSelectionFilterDto.ChallengeId);

            if (challenge.ChallengeState == 6)
            {
                challenge.ChallengeState += 1;
            }

            return(challengeSelectionFilterDto);
        }
Exemplo n.º 6
0
        private ChallengeSelectionFilterDto GetSelectionFilterList(
            ChallengeSelectionFilterDto challengeSelectionFilterDto)
        {
            var filterStatuses =
                _filterStatusRepository.GetSelectionFilter(null, challengeSelectionFilterDto.ChallengeId);
            var reviewFilters   = new List <Filter>();
            var killFilters     = new List <Filter>();
            var keepFilters     = new List <Filter>();
            var multiplyFilters = new List <Filter>();

            foreach (var filterStatus in filterStatuses.Where(y => y.Rank != 0).OrderBy(x => x.Rank))
            {
                switch (filterStatus.Status.Title.ToLower())
                {
                case "review":
                    reviewFilters.Add(filterStatus.Filter);
                    break;

                case "kill":
                    killFilters.Add(filterStatus.Filter);
                    break;

                case "keep":
                    keepFilters.Add(filterStatus.Filter);
                    break;

                case "multiply":
                    multiplyFilters.Add(filterStatus.Filter);
                    break;
                }
            }


            challengeSelectionFilterDto.Keep     = keepFilters.ToList();
            challengeSelectionFilterDto.Review   = reviewFilters;
            challengeSelectionFilterDto.Kill     = killFilters;
            challengeSelectionFilterDto.Multiply = multiplyFilters;

            return(challengeSelectionFilterDto);
        }
Exemplo n.º 7
0
        public FilterIdeaDto GetFilterIdea(Guid challengeId)
        {
            var selectionFilterDto = new ChallengeSelectionFilterDto {
                ChallengeId = challengeId
            };
            var selectionIdeaDto = new ChallengeSelectionIdeaDto {
                ChallengeId = challengeId
            };
            var challengeSelectionFilterDto = _filterStatusService.GetSelectionFilter(selectionFilterDto);
            var challengeSelectionIdeaDto   = _ideaStatusService.GetSelectionIdea(selectionIdeaDto);
            var filterIdeaDto = new FilterIdeaDto
            {
                ChallengeId   = challengeId,
                FilterPasseds = new List <FilterPassedDto>()
            };

            foreach (var filter in challengeSelectionFilterDto.Keep)
            {
                var tmpFilter = new Filter
                {
                    Id          = filter.Id,
                    Title       = filter.Title,
                    Description = filter.Description
                };
                var filterPassedDto = new FilterPassedDto
                {
                    Filter = tmpFilter,
                    Ideas  = challengeSelectionIdeaDto.Keep.Select(x => new Idea
                    {
                        Id          = x.Id,
                        Title       = x.Title,
                        Description = x.Description
                    }).ToList()
                };
                filterIdeaDto.FilterPasseds.Add(filterPassedDto);
            }

            return(filterIdeaDto);
        }