示例#1
0
        public async Task adding_lesson_should_invoke_get_lesson_from_sp_once()
        {
            // Arrange
            var id  = Guid.NewGuid();
            var tId = Guid.NewGuid();
            var tcs = new TaskCompletionSource <Teacher>();

            tcs.SetResult(new Teacher(tId, new User(id, "*****@*****.**", "test", "test", "test", "user")));
            teacherRepositoryMock.Setup(x => x.GetAsync(It.IsAny <Guid>())).Returns(tcs.Task);

            var tcs2 = new TaskCompletionSource <SubjectDto>();

            tcs2.SetResult(new SubjectDto
            {
                Name     = "Biology",
                Category = "Science"
            });

            subjectProviderMock.Setup(x => x.GetAsync(It.IsAny <string>(), It.IsAny <string>())).Returns(tcs2.Task);

            // Act
            await lessonService.AddAsync(id, "Biology", "Science", "Elementary", 10M);

            // Assert
            subjectProviderMock.Verify(x => x.GetAsync("Biology", "Science"), Times.Once());
            teacherRepositoryMock.Verify(y => y.GetAsync(It.Is <Guid>(fu => fu.Equals(id))));
        }
        public async Task <IActionResult> Create(LessonDto lessonDto)
        {
            if (await _lessonService.AreThereLesson(lessonDto.LessonName.ToLower(), lessonDto.FkGradeId) == false)
            {
                await _lessonService.AddAsync(_mapper.Map <Lesson>(lessonDto));

                ViewBag.ErrorMessage = "";
                return(RedirectToAction("GetAll", "Lesson"));
            }
            ViewBag.ErrorMessage = "Sistemde aynı isme ait ders bulunmaktadır...!";
            return(View(lessonDto));
        }
示例#3
0
 public async Task HandleAsync(AddLesson command)
 {
     await _lessonService.AddAsync(command.UserId, command.Name, command.Category, command.Grade, command.PricePerHour);
 }
示例#4
0
        public async Task SeedAsync()
        {
            var users = await _userService.BrowseAsync();

            if (users.Any())
            {
                goto TeachersIni;
            }


            for (int i = 1; i <= 10; i++)
            {
                Guid userId = Guid.NewGuid();

                await _userService.RegisterAsync(userId, $"test{i}@email.com", $"secret{i}", $"username{i}", "user");

                var user = _userService.GetAsync(userId);
            }
            for (int i = 1; i <= 3; i++)
            {
                Guid userIdADmin = Guid.NewGuid();

                await _userService.RegisterAsync(userIdADmin, $"testadmin{i}@email.com", $"secretAdmin", $"usernameAdmin{i}", "admin");
            }
            for (int i = 11; i <= 30; i++)
            {
                Guid userId = Guid.NewGuid();

                await _userService.RegisterAsync(userId, $"test{i}@email.com", $"secret{i}", $"username{i}", "user");
            }

TeachersIni:

            var teachers = await _teacherService.BrowseAsync();

            if (teachers.Any())
            {
                return;
            }


            for (int i = 1; i <= 10; i++)
            {
                var user = await _userService.GetAsync($"test{i}@email.com");

                var id = Guid.NewGuid();
                await _teacherService.CreateAsync(id, user.Id);
            }
            for (int i = 1; i <= 3; i++)
            {
                var u = await _userService.GetAsync($"test{i}@email.com");

                await _lessonService.AddAsync(u.Id, "Biology", "Science", "Elementary", 100M);
            }

            // for(int i = 1; i <= 3; i++)
            // {
            //     var user = await _userService.GetAsync($"test{i}@email.com");
            //     await _availableTimePeriodService.AddTimePeriodAsync(user.Id, new DateTime(2016,12,6,12,15,00), new DateTime(2016,12,6,13,15,00));

            //     await _availableTimePeriodService.AddTimePeriodAsync(user.Id, new DateTime(2015,12,6,14,15,00), new DateTime(2015,12,6,15,15,00));

            // }
        }