コード例 #1
0
        public async Task AddTaskTest(string taskDesc, int priority, string startDatestr, string endDatestr)
        {
            DateTime startDate = DateTime.Parse(startDatestr);
            DateTime endDate   = DateTime.Parse(endDatestr);
            var      taskAdd   = new TaskAdd
            {
                TaskDescription = taskDesc,
                Priority        = priority,
                StartDate       = startDate,
                EndDate         = endDate
            };
            var resulTasks = new Tasks
            {
                EndDate      = endDate,
                Priortiy     = priority,
                TaskDeatails = taskDesc,
                Status       = 1,
                StartDate    = startDate,
                TaskId       = 1
            };
            var mockMapper = new Mock <IMapper>();

            mockMapper.Setup(map => map.Map <Tasks>(It.IsAny <TaskAdd>())).Returns(resulTasks);
            var mockTaskRepo = new Mock <ITaskRepo>();

            mockTaskRepo.Setup(tskService => tskService.AddTask(It.IsAny <Tasks>()))
            .Returns(Task.FromResult <bool>(true));
            var taskService = new TasksService(mockMapper.Object, mockTaskRepo.Object, logger);
            var result      = await taskService.AddTask(taskAdd);

            Assert.True(result);
        }
コード例 #2
0
        public void OnAddTaskClick()
        {
            tasksService.AddTask(NewTaskName, SelectedCategoryIds);

            NewTaskName = string.Empty;
            SelectedCategoryIds.Clear();
        }
コード例 #3
0
        public async Task <IActionResult> Create(ToDoTask task)
        {
            try
            {
                await _tasksService.AddTask(task);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
コード例 #4
0
ファイル: Menu.cs プロジェクト: RupertAvery/QuizApp
        public void CreateNewQuiz()
        {
            _menuView.GiveQuizName();
            string quizName = Console.ReadLine();
            Quiz   newQuiz  = Quiz.Create(quizName);

            Console.Clear();

            CreateQuestions(newQuiz);

            if (newQuiz.HasQuestions())
            {
                _tasksService.AddTask(_db.SaveQuiz(newQuiz));
            }
        }
コード例 #5
0
        public async Task AddTask_Should_Add_Task()
        {
            var expectedRepositoryCount = 5;

            var newTask = new ToDoTask {
                Id = 0, Title = "new test task", IsDone = false
            };

            await _tasksService.AddTask(newTask);

            var allTasks = await _repository.GetAllTasks();

            var tasksCount = allTasks.Count;

            Assert.Equal(expectedRepositoryCount, tasksCount);
        }
コード例 #6
0
        public IActionResult Add_Task([FromRoute] Guid usersid, [FromBody] Tasks task)
        {
            try
            {
                TasksService TasksService = new TasksService();

                if (TasksService.AddTask(task, usersid))
                {
                    return(Ok());
                }
                return(StatusCode(422));
            }
            catch (Exception e)
            {
                throw e;
            }
        }
コード例 #7
0
 public ActionResult CreateTask(Task task)
 {
     tasksService.AddTask(task);
     return(RedirectToAction("Details", "Projects", new { id = task.ProjectID }));
 }