Example #1
0
        public void SiteCreated(SiteCreatedIntegrationEvent @event)
        {
            //Do SomeThing
            _logger.LogInformation($"1.关注接收到 SiteCreated 集成事件,参数Id={@event.Id}");

            _testRepository.Add(new Domain.Test("Test2"));  //测试失败
            var i = _testRepository.UnitOfWork.SaveChangesAsync().Result;
        }
        public async Task <IActionResult> Post(TestForAddDTO model)
        {
            Test test = mapper.Map <Test>(model);
            await testRepository.Add(test).ConfigureAwait(true);

            await unitOfWork.CompleteAsync().ConfigureAwait(true);

            return(Ok(mapper.Map <TestForGetDTO>(await testRepository.Get(test.Id).ConfigureAwait(true))));
        }
        public async Task <ActionResult> NewProdut()
        {
            _testRepository.Add(new Product()
            {
                Name = "PS4"
            });

            return(Ok());
        }
Example #4
0
        public async Task <IActionResult> AddTest(Test test)
        {
            _testRepository.Add <Test>(test);

            if (await _testRepository.SaveAll())
            {
                return(Ok());
            }

            return(BadRequest("Nie udało się dodać testu"));
        }
        public TestModel TestFunction()
        {
            TestViewModel model = new TestViewModel()
            {
                Content = Guid.NewGuid().ToString()
            };
            TestModel addModel = _mapper.Map <TestViewModel, TestModel> (model);

            _testRepository.Add(addModel);
            SaveChange();
            return(addModel);
        }
        private async Task <string> PullData(int pageStartIndex, int pageEndIndex, string dataUrl, ClassifyIdEnum classifyId)
        {
            var successCount = 0;
            var errorCount   = 0;

            for (int pageIndex = pageStartIndex; pageIndex <= pageEndIndex; pageIndex++)
            {
                var(tests, errorJobs) = XinCePingSpider.Take($"{dataUrl}{pageIndex}", classifyId);
                if (errorJobs != null && errorJobs.Any())
                {
                    errorCount += await _testErrorJobRepository.Add(errorJobs);
                }

                foreach (var item in tests)
                {
                    var isExist = await _testRepository.QueryAsQueryable(a => a.OtherId == item.OtherId && a.SourceId == (int)SourceIdEnum.心评测).AnyAsync();

                    if (isExist)
                    {
                        continue;
                    }

                    if (!CheckTest(item))
                    {
                        continue;
                    }

                    var testId = _testRepository.Add(item).Result;
                    SetTestId(item, testId);
                    var insertCount = await _testLabelRepository.Add(item.TestLabels);

                    foreach (var title in item.TestTitles)
                    {
                        var testTitleId = await _testTitleRepository.Add(title);

                        SetTestTitleId(title, testTitleId);

                        foreach (var option in title.TestOptions)
                        {
                            var optionId = await _testOptionRepository.Add(option);

                            var answer = title.TestAnswers.Where(a => a.FlagId == option.FlagId).FirstOrDefault();
                            SetTestOptionId(answer, optionId);
                            await _testAnswerRepository.Add(answer);
                        }
                    }
                    successCount += 1;
                }
            }

            return($"本次爬取页数为:{pageEndIndex - pageStartIndex} 成功采集数据:{successCount}条 异常采集:{errorCount}条");
        }
    public void Can_Add_Entity()
    {
        // Arrange
        var entity = new TestEntity("A", "B", "C", false);

        _connection.AddResultForDataReader(cmd => cmd.CommandText == "INSERT INTO...",
                                           new[] { new TestEntity("A", "B", "C", true) });

        // Act
        var actual = _repository.Add(entity);

        // Assert
        actual.Code.Should().Be(entity.Code);
        actual.CodeType.Should().Be(entity.CodeType);
        actual.Description.Should().Be(entity.Description);
        actual.IsExistingEntity.Should().BeTrue();
    }
        public bool CreateTest(TestsViewModel testsViewModel)
        {
            Test test;
            IEnumerable <TestsViewModel> testsViewModelList;

            testsViewModelList = GetAllTestByTestMasterID(testsViewModel.TestMasterID, "true");
            int maxSequence = testsViewModelList.Count() > 0 ?testsViewModelList.Max(o => o.Sequence) + 1:1;

            testsViewModel.Sequence = maxSequence;
            test = _iMapper.Map <TestsViewModel, Test>(testsViewModel);

            testRepository.Add(test);
            //  throw new Exception("this is ex");
            SaveTest();

            return(test.TestID > 0);
        }
Example #9
0
        public async Task <ICommandResult <Test> > ExecuteAsync(CreateOrUpdateTestCommand command)
        {
            var test = await _testRepository.Get(command.Name, command.ClassName, command.ProjectId);

            if (test == null)
            {
                test = new Test
                {
                    Id        = Guid.NewGuid(),
                    Name      = command.Name,
                    ClassName = command.ClassName,
                    ProjectId = command.ProjectId
                };
                await _testRepository.Add(test);
            }

            return(new CommandResult <Test>(true, test));
        }
Example #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public async Task <bool> Add(TestModel model)
        {
            bool result = await repo.Add(model);

            if (result)
            {
                if (settings.MemCached.Enabled)
                {
                    _ = await memCachedService.Remove(MemCachedType.Test.GetAll);
                }

                if (settings.ClientCache.Enabled)
                {
                    await clientCacheService.Set(ClientCacheType.Test.GetAll);
                }

                return(true);
            }

            return(result);
        }
Example #11
0
        public async Task <ActionResult <Result <string> > > SaveTestWork(TestWorkDTO testWorkDTO)
        {
            _logger.Information($"Enter into method.");
            try
            {
                TestWork testWork = new TestWork();
                if (testWorkDTO.Attributes != null && testWorkDTO.Attributes.Count() > 0)
                {
                    foreach (var item in testWorkDTO.Attributes)
                    {
                        if (_testRepository.ValidInsertAttributeByEmailAddress(testWorkDTO.Email, item))
                        {
                            _testRepository.Add(new TestWork()
                            {
                                Key        = testWorkDTO.Key,
                                Email      = testWorkDTO.Email,
                                CrDate     = DateTime.Now,
                                Attributes = item
                            });
                        }
                    }
                    var result = await _testRepository.UnitOfWork.SaveChangesAsync();

                    var listAttributes = _testRepository.Get10AttributeByEmailAddress(testWorkDTO.Email);
                    if (listAttributes.Count() == 10)
                    {
                        Common.SendMail(testWorkDTO.Email, listAttributes);
                    }
                    _logger.Information($"After save information: {result.ToString()}");
                }
                testWorkDTO.Email = Common.CalculateHash(testWorkDTO.Email);
                _logger.Error($"Input object content: {JsonConvert.SerializeObject(testWorkDTO)}");
            }
            catch (Exception ex)
            {
                _logger.Error($"Exception. Message: {ex.Message}");
            }
            return(Ok("success"));
        }
Example #12
0
        public async Task <CreateTestResponse> CreateOrUpdateTestAsync(Test test, string userEmail)
        {
            var existingUser = await _userRepository.FindByEmailAsync(userEmail);

            if (existingUser == null)
            {
                return(new CreateTestResponse(false, "Email does not belong to a registered user.", null));
            }
            // TODO :: CHECK IF USER IS TOKEN USER
            //https://stackoverflow.com/questions/46112258/how-do-i-get-current-user-in-net-core-web-api-from-jwt-token
            test.UserId = existingUser.Id;
            if (test.Id == 0)
            {
                _testRepository.Add(test);
            }
            else
            {
                _testRepository.Update(test);
            }
            await _unitOfWork.CompleteAsync();

            return(new CreateTestResponse(true, null, test));
        }
 public void SaveResult(string result)
 {
     _testRepository.Add(new Test(result));
 }
Example #14
0
 void ITestService.Create(TestEntity e)
 {
     _repository.Add(e);
 }
Example #15
0
 public async Task <Test> Add(Test test)
 {
     return(await _testRepository.Add(test));
 }
Example #16
0
        public Test Add(TestDtoInput entity)
        {
            var test = _objectMapper.Map <Test>(entity);

            return(_testRepository.Add(test));
        }
Example #17
0
 public void Add(Test entity)
 {
     _ITestRepository.Add(entity);
 }
Example #18
0
 public Test Add(Test entity)
 {
     return(_testRepository.Add(entity));
 }
Example #19
0
 public bool AddNewTestModel(TestModel testModel)
 {
     return(testRepository.Add(testModel));
 }
Example #20
0
 public void CreateTest(Test test)
 {
     testRepository.Add(test);
 }
Example #21
0
 public async Task <TestDto> Post(TestDto testDto)
 {
     return(_mapper.ToDto(await _testRepository.Add(_mapper.FromDto(testDto))));
 }
Example #22
0
 public IActionResult AddTest([FromBody] Test model)
 {
     test_repo.Add(model);
     return(new OkObjectResult(new { TestID = model.TestId }));
 }