Example #1
0
 public EditTaskView(string title, Task task)
 {
     InitializeComponent();
       TaskStatus.ItemsSource = new string[] { "Open", "Closed", "On Hold" };
       this.Title = title;
       this.DataContext = task;
       taskToEdit = task;
 }
Example #2
0
 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);
       }
 }
Example #3
0
 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);
       }
 }
Example #4
0
 public NewTaskViewModel()
 {
     AddTask = new RelayCommand(() => {
     var taskToAdd = new Task {
       Title = Title,
       AssignedTo = AssignedTo,
       Status = Status,
       Details = Details
     };
     Messenger.Default.Send(new Events.AddTaskEvent(taskToAdd));
       });
 }
Example #5
0
        // 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);
        }
Example #6
0
        // 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);
        }
Example #7
0
 public AddTaskEvent(Task taskToAdd)
 {
     TaskToAdd = taskToAdd;
 }
Example #8
0
 public AddedTaskEvent(Task task)
 {
     AddedTask = task;
 }
Example #9
0
 public UpdateTaskEvent(Task taskToUpdate)
 {
     TaskToUpdate = taskToUpdate;
 }
Example #10
0
 public DeletedTaskEvent(Task task)
 {
     DeletedTask = task;
 }
Example #11
0
 public void AddTask(Task taskToAdd)
 {
 }
Example #12
0
 public DeleteTaskEvent(Task taskToDelete)
 {
     TaskToDelete = taskToDelete;
 }
Example #13
0
 public UpdatedTaskEvent(Task task)
 {
     UpdatedTask = task;
 }
Example #14
0
 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);
       }
 }
Example #15
0
 public void DeleteTask(Task taskToDelete)
 {
 }
Example #16
0
 public void UpdateTask(Task taskToUpdate)
 {
 }
Example #17
0
 public void UpdateTask(Task taskToUpdate)
 {
     hubProxy.Invoke("UpdateTask", taskToUpdate);
 }
Example #18
0
 public void AddTask(Task taskToAdd)
 {
     hubProxy.Invoke("AddTask", taskToAdd);
 }
Example #19
0
 public void DeleteTask(Task taskToDelete)
 {
     hubProxy.Invoke("DeleteTask", taskToDelete);
 }
Example #20
0
 public TaskSelectedForEditEvent(Task task)
 {
     Task = task;
 }
Example #21
0
        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);
              }
        }