public EditTaskView(string title, Task task) { InitializeComponent(); TaskStatus.ItemsSource = new string[] { "Open", "Closed", "On Hold" }; this.Title = title; this.DataContext = task; taskToEdit = task; }
public void AddTask(Task task) { try { task.DateCreated = DateTime.Now; taskEntities.Tasks.Add(task); taskEntities.SaveChanges(); Clients[task.AssignedTo].AddedTask(task); sendLogMessage(string.Format("{0} has added task '{1}'.", getCurrentUser().Username, task.Title)); } catch (Exception ex) { exceptionEncountered(ex); } }
public void DeleteTask(Task taskToDelete) { try { var task = taskEntities.Tasks.Find(taskToDelete.TaskID); task.IsDeleted = true; taskEntities.SaveChanges(); Clients[taskToDelete.AssignedTo].DeletedTask(task); sendLogMessage(string.Format("{0} has deleted task '{1}'.", getCurrentUser().Username, task.Title)); } catch (Exception ex) { exceptionEncountered(ex); } }
public NewTaskViewModel() { AddTask = new RelayCommand(() => { var taskToAdd = new Task { Title = Title, AssignedTo = AssignedTo, Status = Status, Details = Details }; Messenger.Default.Send(new Events.AddTaskEvent(taskToAdd)); }); }
// POST /api/tasks public HttpResponseMessage<Task> Post(Task task) { if (ModelState.IsValid) { task.DateCreated = DateTime.Now; taskEntities.Tasks.Add(task); taskEntities.SaveChanges(); var response = new HttpResponseMessage<Task>(task, HttpStatusCode.Created); string uri = Url.Route(null, new { id = task.TaskID }); response.Headers.Location = new Uri(Request.RequestUri, uri); return response; } throw new HttpResponseException(HttpStatusCode.BadRequest); }
// PUT /api/tasks/5 public HttpResponseMessage Put(int id, Task task) { if (ModelState.IsValid) { var taskToUpdate = Get(task.TaskID); if (taskToUpdate == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } taskToUpdate.AssignedTo = task.AssignedTo; taskToUpdate.Details = task.Details; taskToUpdate.Status = task.Status; taskToUpdate.Title = task.Title; taskEntities.SaveChanges(); return new HttpResponseMessage(HttpStatusCode.NoContent); } throw new HttpResponseException(HttpStatusCode.BadRequest); }
public AddTaskEvent(Task taskToAdd) { TaskToAdd = taskToAdd; }
public AddedTaskEvent(Task task) { AddedTask = task; }
public UpdateTaskEvent(Task taskToUpdate) { TaskToUpdate = taskToUpdate; }
public DeletedTaskEvent(Task task) { DeletedTask = task; }
public void AddTask(Task taskToAdd) { }
public DeleteTaskEvent(Task taskToDelete) { TaskToDelete = taskToDelete; }
public UpdatedTaskEvent(Task task) { UpdatedTask = task; }
public void Login(string username) { try { ConnectedUser existingUser = taskEntities.ConnectedUsers.SingleOrDefault(c => c.ConnectionID == Context.ConnectionId); if (existingUser == null) { taskEntities.ConnectedUsers.Add(new ConnectedUser { ConnectionID = Context.ConnectionId, Username = username }); taskEntities.SaveChanges(); } IEnumerable<Task> existingUserTasks = taskEntities.Tasks.Where(u => u.AssignedTo == username); if (!existingUserTasks.Any()) { var newTask = new Task { AssignedTo = username, DateCreated = DateTime.Now, Details = "Welcome to TaskR! Now delete this task and create some of your own.", Status = "Open", Title = "Your First Task" }; taskEntities.Tasks.Add(newTask); taskEntities.SaveChanges(); } Groups.Add(Context.ConnectionId, username); GetTasksForUser(username); sendLogMessage(username + " has logged in"); } catch (Exception ex) { exceptionEncountered(ex); } }
public void DeleteTask(Task taskToDelete) { }
public void UpdateTask(Task taskToUpdate) { }
public void UpdateTask(Task taskToUpdate) { hubProxy.Invoke("UpdateTask", taskToUpdate); }
public void AddTask(Task taskToAdd) { hubProxy.Invoke("AddTask", taskToAdd); }
public void DeleteTask(Task taskToDelete) { hubProxy.Invoke("DeleteTask", taskToDelete); }
public TaskSelectedForEditEvent(Task task) { Task = task; }
public void UpdateTask(Task task) { try { Task existingTask = taskEntities.Tasks.Find(task.TaskID); if (existingTask == null) { throw new Exception("Unable to find an existing task in the database"); } existingTask.Details = task.Details; existingTask.Status = task.Status; existingTask.Title = task.Title; bool assignmentChanged = task.AssignedTo != existingTask.AssignedTo; string originallyAssignedTo = existingTask.AssignedTo; existingTask.AssignedTo = task.AssignedTo; taskEntities.SaveChanges(); if (assignmentChanged) { Clients[originallyAssignedTo].UpdatedTask(existingTask); } Clients[task.AssignedTo].UpdatedTask(existingTask); sendLogMessage(string.Format("{0} has updated task '{1}'.", getCurrentUser().Username, task.Title)); } catch (Exception ex) { exceptionEncountered(ex); } }