コード例 #1
0
        public IActionResult CreateTask(CreateTaskData createTaskData)
        {
            Random i = new Random();

            var existingTask = _commonContext
                               .Tasks
                               .FirstOrDefault(x => x.Name == createTaskData.Name);

            if (existingTask != null)
            {
                return(View("Pages/CreateTask.cshtml"));
            }

            var executorIds   = _commonContext.Users.Where(x => x.Role.Name == "Executor").Select(x => x.Id).ToList();
            var executorIndex = i.Next(executorIds.Count - 1);
            var executorId    = executorIds[executorIndex];

            var newTask = new Task
            {
                Name            = createTaskData.Name,
                Id              = createTaskData.Id,
                Description     = createTaskData.Description,
                CreatorId       = createTaskData.CreatorId,
                ExecutorId      = executorId,
                Status          = i.Next(2),
                Priority        = i.Next(3),
                CreatedDateTime = DateTime.Now,
                ClosedDateTime  = DateTime.Now.AddDays(i.Next(1, 5))
            };

            _commonContext.Tasks.Add(newTask);
            _commonContext.SaveChanges();

            return(View("Pages/Index.cshtml"));
        }
コード例 #2
0
ファイル: TasksController.cs プロジェクト: NPerederiy/e-diary
 public async Task <CreateTaskResponseData> CreateTaskAsync(CreateTaskData task)
 {
     Services.Validation.Validate.NotNull(task);
     Services.Validation.Validate.NotNull(task.Header, "Task header");
     Services.Validation.Validate.NotNull(task.SectionId, "Section id");
     return(await ts.CreateTaskAsync(task.Header, task.SectionId));
 }
コード例 #3
0
 public CreateTaskObject()
 {
     data = new CreateTaskData();
     meta = new CreateTaskMeta();
 }