public async Task <int> Handle(CreateSubTaskCommand request, CancellationToken cancellationToken) { var projectId = _context.Tasks.Where(x => x.TaskId == request.TaskId).Select(x => x.ProjectId).FirstOrDefault(); Domain.MySql.Task task = new Domain.MySql.Task() { ProjectId = projectId, ParentTaskId = request.TaskId, StatusId = _context.Statuscodes.Where(x => x.Name.ToLower() == "open").Select(x => x.StatusId).FirstOrDefault(), Name = request.Name, Description = request.Description, Size = request.Size }; _context.Tasks.Add(task); await _context.SaveChangesAsync(cancellationToken); return(task.TaskId); }
public async Task <Unit> Handle(CreateTaskForProjectCommand request, CancellationToken cancellationToken) { var currentProject = _context.Projects.Where(x => x.ProjectId == request.model.ProjectId).FirstOrDefault(); var project = new Domain.MySql.Task() { TaskId = 0, Name = request.model.Name, Description = request.model.Description, ProjectId = request.model.ProjectId, FrequencyStartDate = request.model.FrequencyStartDate, ReminderDate = request.model.ReminderDate, Size = request.model.Size, StatusId = _context.Statuscodes.Where(x => x.Name.ToLower() == "open").Select(x => x.StatusId).FirstOrDefault() }; await _context.Tasks.AddAsync(project); await _context.SaveChangesAsync(cancellationToken); return(new Unit()); }