Пример #1
0
        public void MergeWordsOneChildTest()
        {
            var thisWord = Util.RandomWord(ProjId);

            thisWord = _wordRepo.Create(thisWord).Result;

            var mergeObject = new MergeWords
            {
                Parent   = thisWord,
                Children = new List <MergeSourceWord>
                {
                    new MergeSourceWord {
                        SrcWordId = thisWord.Id
                    }
                }
            };

            var newWords = _mergeService.Merge(ProjId, new List <MergeWords> {
                mergeObject
            }).Result;

            // There should only be 1 word added and it should be identical to what we passed in
            Assert.That(newWords, Has.Count.EqualTo(1));
            Assert.That(newWords.First().ContentEquals(thisWord));

            // Check that the only word in the frontier is the new word
            var frontier = _wordRepo.GetFrontier(ProjId).Result;

            Assert.That(frontier, Has.Count.EqualTo(1));
            Assert.That(frontier.First(), Is.EqualTo(newWords.First()));

            // Check that new word has the right history
            Assert.That(newWords.First().History, Has.Count.EqualTo(1));
            Assert.That(newWords.First().History.First(), Is.EqualTo(thisWord.Id));
        }
    public async Task <ActionResult> Merge(
        string clubInitials,
        MergeCompetitorViewModel vm)
    {
        var clubId = await _clubService.GetClubId(clubInitials);

        if (!await _authService.CanUserEdit(User, clubId))
        {
            return(Unauthorized());
        }
        vm.SourceCompetitor = await _competitorService.GetCompetitorAsync(vm.SourceCompetitorId.Value);

        vm.TargetCompetitor = await _competitorService.GetCompetitorAsync(vm.TargetCompetitorId.Value);

        if (vm.SourceCompetitor.ClubId != clubId ||
            vm.TargetCompetitor.ClubId != clubId)
        {
            return(Unauthorized());
        }
        await _mergeService.Merge(
            vm.TargetCompetitorId,
            vm.SourceCompetitorId,
            await GetUserStringAsync());

        vm.TargetNumberOfRaces = await _mergeService.GetNumberOfRaces(vm.TargetCompetitorId);

        return(View("Done", vm));
    }
Пример #3
0
        public override int Run(string[] remainingArguments)
        {
            _optionalArgumentList.ForEach(item =>
                                          Console.WriteLine(@"List Item {0} = ""{1}""", _optionalArgumentList.IndexOf(item), item));

            var counselors = _repository.ListAsync <Counselor>().Result;

            _logger.LogInformation("Vejledere: " + counselors.Count);

            var events = _repository.ListAsync <Event>().Result;

            _logger.LogInformation("Arrangementer: " + events.Count);

            var locations = _repository.ListAsync <Location>().Result;

            _logger.LogInformation("Steder: " + locations.Count);

            var requests = _repository.ListAsync <Request>().Result;

            _logger.LogInformation("Ønsker: " + requests.Count);

            _mergeService.Merge();

            return(0);
        }
Пример #4
0
        public async Task <IActionResult> MergeWords(
            string projectId, [FromBody, BindRequired] List <MergeWords> mergeWordsList)
        {
            if (!await _permissionService.HasProjectPermission(HttpContext, Permission.MergeAndCharSet))
            {
                return(Forbid());
            }

            try
            {
                var newWords = await _mergeService.Merge(projectId, mergeWordsList);

                return(Ok(newWords.Select(w => w.Id).ToList()));
            }
            catch
            {
                return(BadRequest("Merge failed."));
            }
        }
Пример #5
0
 public string Merge(_Command command)
 {
     return(mergeService.Merge(command));
 }