Example #1
0
 static public WorkItemSnapshot Map(WorkItemCreateDto workItem)
 {
     return(new WorkItemSnapshot()
     {
         ParentId = workItem.ParentId,
         Title = workItem.Title,
         Description = workItem.Description,
         Executors = workItem.Executors,
         PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(workItem.PlannedExecutionTime).ExecutionTimeInSeconds,
         ActualExecutionTime = WorkItemExecutionTime.FromTimeSpan(workItem.ActualExecutionTime).ExecutionTimeInSeconds,
         Status = workItem.Status,
         EndedAt = workItem.Status == WorkItemStatus.COMPLETED ? DateTime.Now : (DateTime?)null,
         CreatedAt = DateTime.Now
     });
 }
        public async Task <IActionResult> SubmitEdit(int id, WorkItemUpdateDto dto)
        {
            var workItem = await repo.GetWorkItem(id);

            if (workItem == null)
            {
                throw new WorkItemNotFound();
            }

            workItem.SetTitle(dto.Title);
            workItem.SetDescription(dto.Description);
            workItem.SetExecutors(dto.Executors);
            workItem.SetPlannedExecutionTime(WorkItemExecutionTime.FromTimeSpan(dto.PlannedExecutionTime));
            workItem.SetActualExecutionTime(WorkItemExecutionTime.FromTimeSpan(dto.ActualExecutionTime));
            workItem.SetStatus(dto.Status);

            await repo.UpdateWorkItem(workItem);

            return(RedirectToAction("Index"));
        }
Example #3
0
        public static void FillDatabaseWithValues(IWebHost host)
        {
            using (var scope = host.Services.CreateScope())
            {
                var repo = scope.ServiceProvider.GetRequiredService <IWorkItemRepository>();

                if (repo.GetWorkItems().Result.Count() == 0)
                {
                    var wi1 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Система управления задачами",
                        Description          = "Разработка системы управления задачами",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    var wi2 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Бизнес-логика",
                        Description          = "Разработка бизнес-логики проекта управления задачами",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi2.SetParent(wi1);

                    var wi3 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Изменение статуса задач",
                        Description          = "Реализовать возможность изменения статуса задач в соответсвии с требованиями",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi3.SetParent(wi2);

                    var wi4 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Рассчет времени выполнения здачи",
                        Description          = "Реализовать возможность вычислять время выполнения задачи в соответсвии с требованиями",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi4.SetParent(wi2);

                    var wi5 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Управление деревом подзадач",
                        Description          = "Корректно отрабатывать изменения в структуре дерева задач",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi5.SetParent(wi2);

                    var wi6 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Перевод задачи в статус Звершена",
                        Description          = "Переводить все подзадачи данной задачи в статус Завершена",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi6.SetParent(wi2);

                    var wi7 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Хранение данных",
                        Description          = "Возможность сохранять задачи в базе данных Microsoft SQL Server",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi7.SetParent(wi1);

                    var wi8 = WorkItem.Create(new WorkItemSnapshot()
                    {
                        Title                = "Пользовательский интерфейс",
                        Description          = "Разработка пользовательского интерфейса в соответствии с требованиями",
                        Executors            = "Игорь Кокорин",
                        Status               = WorkItemStatus.ASSIGNED,
                        PlannedExecutionTime = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        ActualExecutionTime  = WorkItemExecutionTime.FromTimeSpan(TimeSpan.FromHours(5)).ExecutionTimeInSeconds,
                        CreatedAt            = DateTime.Now
                    });

                    wi8.SetParent(wi1);

                    repo.CreateWorkItem(wi1).Wait();
                }
            }
        }