public void CreateTask(TasksCreateViewModel model)
        {
            var task = new Task
            {
                Title        = model.Title,
                DueDate      = DateTime.Parse(model.DueDate),
                Description  = model.Description,
                Participants = model.Participants
            };

            this.context.Tasks.Add(task);
            this.context.SaveChanges();

            if (model.AffectedSectors.Any())
            {
                foreach (string sector in model.AffectedSectors.Where(s => !string.IsNullOrWhiteSpace(s)))
                {
                    task.AffectedSectors.Add(new TaskSector {
                        Sector = Enum.Parse <Sector>(sector)
                    });
                }

                this.context.SaveChanges();
            }
        }
        /// <summary>
        /// Manuel Mairinger Created
        /// </summary>
        /// <param name="projectId"></param>
        /// <returns></returns>

        public IActionResult Create(int projectId)
        {
            TasksCreateViewModel model = new TasksCreateViewModel();

            if (projectId != 0)
            {
                model.LoadData(_unitOfWork, projectId);
            }
            else
            {
                model.LoadData(_unitOfWork, 6969);
            }

            model.Project = _unitOfWork.Projects.GetById(model.ProjectId);
            return(View(model));
        }
        public IActionResult Create(TasksCreateViewModel model)
        {
            model.Task.ProjectId = model.Project.Id;


            _unitOfWork.Tasks.Add(model.Task);

            if (model.EmployeeTask.EmployeeId != 0)
            {
                Employee emp = new Employee();
                emp = _unitOfWork.Employees.GetById(model.EmployeeTask.EmployeeId);
                model.EmployeeTask.Employee = emp;
                model.EmployeeTask.Task     = model.Task;
                _unitOfWork.EmployeeTasks.Add(model.EmployeeTask);
            }

            _unitOfWork.Save();

            return(RedirectToAction("List", "Projects"));
        }
        public IActionResult Create(TasksCreateViewModel model)
        {
            this.tasksService.CreateTask(model);

            return(this.RedirectToAction("/"));
        }