public ListTaskViewModel(TaskEntity taskEntity, ITaskModel taskModel, IEventAggregator eventAggregator) { TaskEntity = taskEntity; _taskModel = taskModel; _eventAggregator = eventAggregator; eventAggregator.Subscribe(this); }
public EditTaskViewModel(ITaskModel taskModel, IEventAggregator eventAggregator, ITaskGroupModel groupModel) { _taskModel = taskModel; _eventAggregator = eventAggregator; _groupModel = groupModel; CreateNew(); _eventAggregator.Subscribe(this); }
public TaskGroupListViewModel(ITaskModel taskModel, ITaskGroupModel groupModel, IEventAggregator eventAggregator, EntityToVmConverter vmConverter, List <IBaseModel> models) { _taskModel = taskModel; _groupModel = groupModel; _eventAggregator = eventAggregator; _vmConverter = vmConverter; _models = models; eventAggregator.Subscribe(this); }
private string[] BuildPropertiesStrings(ITaskModel task) { return(new string[] { $"\u0022{task.Name}\u0022", $"\u0022{task.Description}\u0022", $"\u0022{task.StartDate.ToString()}\u0022", $"\u0022{task.EndDate.ToString()}\u0022", $"\u0022{task.Important.ToString()}\u0022" }); }
private string GetTaskString(ITaskModel task, int taskId) { string id = taskId.ToString().PadRight(_idLength); string name = task.Name.Substring(0, task.Name.Length > maxLength ? maxLength : task.Name.Length).PadRight(_nameLength); string desc = task.Description.Substring(0, task.Description.Length > maxLength ? maxLength : task.Description.Length).PadRight(_descLength); string important = task.Important.ToString().PadRight(_importanceLength); string startDate = task.StartDate.ToString(_dateFormat); string endDate = task.AllDay ? " -".PadRight(_dateLength) : task.EndDate.ToString(_dateFormat); string allDay = task.AllDay ? " v".PadRight(_allDayLength) : "".PadRight(_allDayLength); return($"| {id} | {name} | {desc} | {important} | {startDate} | {endDate} | {allDay} |"); }
/// <summary> /// Constructor of the class /// </summary> /// <param name="taskModel"></param> /// <param name="targetList"></param> /// <param name="dataConnector"></param> /// <param name="mainPage"></param> /// <param name="state"></param> public DefaultTaskViewModel(ITaskModel taskModel, ObservableCollection<ITaskViewModel> targetList, IDataConnector dataConnector, MainPage mainPage, TaskState state) { TaskModel = taskModel; _targetList = targetList; _dataConnector = dataConnector; ItemVisualWidth = mainPage.ActualWidth; // Commands Break = new ViewModelCommand() { Command = new RelayCommand(r => BreakTask()), Text = "Break" }; PunchOut = new ViewModelCommand { Command = new RelayCommand(r => FinishTask()), Text = "Finished", ImagePath = @"Images/finish.png" }; DeleteFromList = new ViewModelCommand { Command = new RelayCommand( r => { if (targetList != null && targetList.Contains(this)) { targetList.Remove(this); _dataConnector.DeleteTask(taskModel.Id); } }), Text = "Delete", ImagePath = "Images/delete.png" }; // Timer Init _timer = new DispatcherTimer(); _timer.Tick += timer_Tick; _timer.Interval = TimeSpan.FromSeconds(1); _timer.Start(); // Setstate State = state; _initLoad = false; }
/// <summary> /// Save Task to Xml File. /// </summary> /// <param name="task"></param> /// <param name="taskState"></param> public void SaveTask(ITaskModel task, TaskState taskState) { // build the root nodes var rootTask = _rootDocument.CreateElement("Task"); // build the model nodes var startDate = _rootDocument.CreateElement("StartDate"); startDate.InnerText = task.Start.Ticks.ToString(); var endDate = _rootDocument.CreateElement("EndDate"); endDate.InnerText = task.End.Ticks.ToString(); var title = _rootDocument.CreateElement("Title"); title.InnerText = task.Title ?? ""; var id = _rootDocument.CreateElement("Id"); id.InnerText = task.Id.ToString(); var state = _rootDocument.CreateElement("State"); state.InnerText = ((int)taskState).ToString(); var lastBreak = _rootDocument.CreateElement("LastBreak"); lastBreak.InnerText = task.LastBreak.Ticks.ToString(); // Breaks var rootBreaks = _rootDocument.CreateElement("Breaks"); foreach (var timeBreak in task.Breaks) { var pause = _rootDocument.CreateElement("Break"); pause.InnerText = timeBreak.Ticks.ToString(); rootBreaks.AppendChild(pause); } // Add new nodes to Task node and Tasknode to rootNode rootTask.AppendChild(startDate); rootTask.AppendChild(endDate); rootTask.AppendChild(title); rootTask.AppendChild(id); rootTask.AppendChild(state); rootTask.AppendChild(rootBreaks); rootTask.AppendChild(lastBreak); _rootDocument.GetElementsByTagName("Tasks")[0].AppendChild(rootTask); _rootDocument.SaveToFileAsync(_databaseXmlFile); }
public void Invoke() { _console.Write("name;description;start date;end date;importance: ", ConsoleColor.Green); string input = _console.ReadLine(); ITaskModel task = _taskBuilder.Parse(input); if (task != null) { _taskManager.AddTask(task); _console.Write("Task '", ConsoleColor.Green); _console.Write(task.Name, ConsoleColor.Blue); _console.WriteLine("' has been added!", ConsoleColor.Green); } else { _console.WriteLine("Invalid input string!", ConsoleColor.Red); } }
public async Task <ITaskModel> CreateAsync(ITaskModel task) { var newTask = mapper.Map <DAL.Entities.Task>(task); if (string.IsNullOrWhiteSpace(newTask.Name)) { throw new AppException("Task name is required"); } if (await taskRepository.CheckIfExistAsync(newTask.Name)) { throw new AppException("Task name \"" + newTask.Name + "\" is already taken"); } var projectId = await taskRepository.GetProjectIdAsync(task.ProjectName); if (projectId == null) { throw new AppException("Project doesn't exist\"" + task.ProjectName); } var userId = await taskRepository.GetUserIdAsync(task.AssignedOn); if (userId == null) { throw new AppException("User doesn't exist\"" + task.AssignedOn); } newTask.Id = Guid.NewGuid(); newTask.Abrv = task.Name.ToLower(); newTask.DateCreated = DateTime.Now; newTask.DateUpdated = DateTime.Now; newTask.ProjectId = projectId; newTask.AssignedOn = task.AssignedOn; newTask.CreatedBy = task.CreatedBy; newTask.UserId = userId; await taskRepository.CreateAsync(newTask); return(mapper.Map <ITaskModel>(newTask)); }
public EntityToVmConverter(ITaskModel taskModel, ITaskGroupModel groupModel, IEventAggregator eventAggregator) { _taskModel = taskModel; _groupModel = groupModel; _eventAggregator = eventAggregator; }
/// <summary> /// Update Task, delete all and rerwrite. /// </summary> /// <param name="task"></param> /// <param name="state"></param> public void UpdateTask(ITaskModel task, TaskState state) { DeleteTask(task.Id); SaveTask(task, state); }