/// <summary>
 /// Creates new Test.
 /// </summary>
 /// <param name="test"> Test to create.</param>
 public void CreateTest(BllTest test)
 {
     if (test == null)
     {
         throw new ArgumentNullException(nameof(test));
     }
     repository.Create(test.ToDalTest());
     service.Save();
 }
Esempio n. 2
0
 public void CreateTest(TestEntity test)
 {
     if (test == null)
     {
         throw new ArgumentNullException();
     }
     repo.Create(test.ToDal());
     uow.Save();
 }
Esempio n. 3
0
 public IActionResult Create(
     [Bind("TestId,Title,Number,CreatedTime,UpdatedTime,UserId,User,Questions")] Test test)
 {
     if (ModelState.IsValid)
     {
         test.CreatedTime = DateTime.Now;
         test.UpdatedTime = DateTime.Now;
         _testRepository.Create(test);
         return(RedirectToAction("Index", "Home"));
     }
     ViewData["Title"]  = test.Title;
     ViewData["Number"] = test.Number;
     return(View(test));
 }
        public void CreateProductWithoutUnitOfWork()
        {
            var product = new Product {
                Name = "ADSL Modem"
            };

            _repository.Create(product);
            Assert.AreNotEqual(product.Id, 0);
            var productCount = _repository.Query().Count();

            Assert.That(productCount, Is.EqualTo(1));
            var productFromDb = _repository.GetById(product.Id);

            Assert.That(productFromDb, Is.Not.Null);
            Assert.That(productFromDb.Id, Is.EqualTo(product.Id));
            Assert.That(productFromDb.Name, Is.EqualTo(product.Name));
        }
Esempio n. 5
0
        public async Task <Test> RegisterTest(RegisterTestDto registerTestDto)
        {
            if (registerTestDto.Name == "")
            {
                return(null);
            }
            var test = new Test();

            if (registerTestDto.AutomaticCountTime == false)
            {
                test = new Test(Int32.Parse(registerTestDto.SubjectId), registerTestDto.AdditionalInfo, registerTestDto.Name
                                , Int32.Parse(registerTestDto.TypeOfTest), registerTestDto.TimeOfTest, registerTestDto.TeacherId, registerTestDto.AutomaticCountTime);
            }
            else
            {
                test = new Test(Int32.Parse(registerTestDto.SubjectId), registerTestDto.AdditionalInfo, registerTestDto.Name
                                , Int32.Parse(registerTestDto.TypeOfTest), "0", registerTestDto.TeacherId, registerTestDto.AutomaticCountTime);
            }
            testRepository.Create(test);
            await testRepository.SaveChangesAsync();

            return(test);
        }
Esempio n. 6
0
 public Test CreateTest(string name, string description, DateTime dueDate) => m_testRepo.Create(name, description, dueDate);
Esempio n. 7
0
 public void CreateTest(TestEntity e)
 {
     testRepository.Create(e.ToDalTest());
     uow.Commit();
 }
Esempio n. 8
0
 /// <summary>
 /// Creates a test
 /// </summary>
 /// <param name="entity">Test</param>
 public void Create(BllTest entity)
 {
     testRepository.Create(entity.ToDalTest());
     unitOfWork.Commit();
 }