public ProjectViewModel(Project project) { Project = project; }
private void Save() { var task = new Task(); if (Project == null) { if (string.IsNullOrEmpty(ProjectName)) throw new InvalidOperationException("Please fill in project name."); Project = new Project() {Name = ProjectName}; } if (Category == null) { if (string.IsNullOrEmpty(CategoryName)) throw new InvalidOperationException("Please fill in category name."); Category = new Category() {Name = CategoryName}; } Category.Project = Project; task.Category = Category; task.Description = Description ?? string.Empty; task.Started = DateTime.Today.Add(Started); if (Completed.HasValue) task.Completed = DateTime.Today.Add(Completed.Value); task.WorkedHours = WorkedHours; timeManagerRepository.SaveTask(task); Close(); }