Ejemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("TestemonyId,Title,Content,StudentId,Valid,CreationDate")] Testemony testemony)
        {
            if (ModelState.IsValid)
            {
                _context.Add(testemony);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index", "Testemonies", new { userId = testemony.StudentId }));
            }
            ViewData["StudentId"]    = testemony.StudentId;
            ViewData["CreationDate"] = testemony.CreationDate;
            return(View(testemony));
        }
Ejemplo n.º 2
0
        public async Task TestingCreateTestemonySuccessfull()
        {
            InitializeDatabaseWithDataTest();
            TestemoniesController controller = new TestemoniesController(_context);
            // Act
            Testemony testemonyTest = new Testemony
            {
                Title        = "Testing",
                Content      = "Testing",
                StudentId    = _context.Students.Where(s => s.UserFullname.Equals("Teste User 1")).FirstOrDefault().Id,
                Valid        = false,
                CreationDate = new DateTime(2018, 02, 05)
            };

            await controller.Create(testemonyTest);

            int currentInterviewNumber = _context.Testemonies.Count();

            Assert.Equal(2, currentInterviewNumber);
        }