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); }
public void OnAddTaskClick() { tasksService.AddTask(NewTaskName, SelectedCategoryIds); NewTaskName = string.Empty; SelectedCategoryIds.Clear(); }
public async Task <IActionResult> Create(ToDoTask task) { try { await _tasksService.AddTask(task); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
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)); } }
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); }
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; } }
public ActionResult CreateTask(Task task) { tasksService.AddTask(task); return(RedirectToAction("Details", "Projects", new { id = task.ProjectID })); }