public ToDoItem PrepareToDoModel(TeacherTaskMapping userTask) { return(new ToDoItem { TaskId = userTask.Task.Id, Name = userTask.Task.Name, Description = userTask.Task.Description, StatusId = userTask.Task.StatusId, DeadLine = userTask.Task.DeadLine, Subject = userTask.Task.Subject.Name }); }
public JsonResult CreateTask(CreateTaskViewModel task) { var userId = User.GetLoggedInUserId <string>(); var subjectUsers = _subjectService.GetSubjectUsers(task.SubjectId); foreach (var subjectUser in subjectUsers) { var subjectTask = new Task { Name = task.Name, Description = task.Description, DeadLine = task.DeadLine, StatusId = (int)Common.Enums.TaskStatus.Proposed, MaxAssessment = task.MaxAssessment, CreatedById = userId, SubjectId = task.SubjectId, DateCreated = DateTime.UtcNow }; _taskService.CreateTask(subjectTask); var userTaskMapping = new UserTaskMapping { UserId = subjectUser.User.Id, TaskId = subjectTask.Id }; _taskService.CreateUserTaskMapping(userTaskMapping); var teacherTaskMapping = new TeacherTaskMapping { TeacherId = userId, TaskId = subjectTask.Id }; _taskService.CreateTeacherTaskMapping(teacherTaskMapping); } return(CreateJsonResult(true)); }
public void CreateTeacherTaskMapping(TeacherTaskMapping teacherTaskMapping) { _teacherTaskMappingRepository.Insert(teacherTaskMapping); }