Example #1
0
        //добавление задачи
        public Task CreateTask(string name, int workload, DateTime startDate, DateTime endDate, Status status, int performerId)
        {
            var taskRepository = RepositoryFactory.GetTaskRepository();
            var tasks = taskRepository.GetAllEntities();
            ;
            var task = new Task()
            {
                Id = new IdGenerator<Task>().Genarate(tasks),
                Name = name,
                Workload = workload,
                StartDate = startDate,
                EndDate = endDate,
                Status = status,
                PerformerId = performerId
            };

            taskRepository.Create(task);
            try
            {
                UnitOfWork.SaveChanges();
            }
            catch (TaskServiceException exception)
            {
                throw new TaskServiceException(exception);
            }
            UnitOfWork.Dispose();

            return task;
        }
        public ActionResult EditTasks(EditTaskPartialViewModel editTaskPartialViewModel)
        {
            var connectionFactory = new ConnectionFactory(ConnectionResource.ConnectionString);
            var context = new QulixContext(connectionFactory);
            var task = new Task()
            {
                Id = editTaskPartialViewModel.Id,
                Name = editTaskPartialViewModel.Name,
                Workload = editTaskPartialViewModel.Workload,
                StartDate = editTaskPartialViewModel.StartDate,
                EndDate = editTaskPartialViewModel.EndDate,
                Status = editTaskPartialViewModel.Status,
                PerformerId = editTaskPartialViewModel.PerformerId
            };

            using (var uow = context.CreateUnitOfWork())
            {
                var repositoryFactory = new RepositoryFactory(context);
                var taskService = new TaskService(uow, repositoryFactory);
                taskService.UpdateTask(task);
                uow.SaveChanges();
                return RedirectToAction("ViewTasks", "Home");
            }
        }
Example #3
0
        //обновление задачи
        public void UpdateTask(Task task)
        {
            var taskRepository = RepositoryFactory.GetTaskRepository();

            try
            {
                taskRepository.Update(task);
            }
            catch (TaskServiceException exception)
            {
                throw new TaskServiceException(exception);
            }
        }