Esempio n. 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;
 }
Esempio n. 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);
       }
 }
Esempio n. 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);
       }
 }
Esempio n. 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));
       });
 }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 7
0
 public AddTaskEvent(Task taskToAdd)
 {
     TaskToAdd = taskToAdd;
 }
Esempio n. 8
0
 public AddedTaskEvent(Task task)
 {
     AddedTask = task;
 }
Esempio n. 9
0
 public UpdateTaskEvent(Task taskToUpdate)
 {
     TaskToUpdate = taskToUpdate;
 }
Esempio n. 10
0
 public DeletedTaskEvent(Task task)
 {
     DeletedTask = task;
 }
Esempio n. 11
0
 public void AddTask(Task taskToAdd)
 {
 }
Esempio n. 12
0
 public DeleteTaskEvent(Task taskToDelete)
 {
     TaskToDelete = taskToDelete;
 }
Esempio n. 13
0
 public UpdatedTaskEvent(Task task)
 {
     UpdatedTask = task;
 }
Esempio n. 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);
       }
 }
Esempio n. 15
0
 public void DeleteTask(Task taskToDelete)
 {
 }
Esempio n. 16
0
 public void UpdateTask(Task taskToUpdate)
 {
 }
Esempio n. 17
0
 public void UpdateTask(Task taskToUpdate)
 {
     hubProxy.Invoke("UpdateTask", taskToUpdate);
 }
Esempio n. 18
0
 public void AddTask(Task taskToAdd)
 {
     hubProxy.Invoke("AddTask", taskToAdd);
 }
Esempio n. 19
0
 public void DeleteTask(Task taskToDelete)
 {
     hubProxy.Invoke("DeleteTask", taskToDelete);
 }
Esempio n. 20
0
 public TaskSelectedForEditEvent(Task task)
 {
     Task = task;
 }
Esempio n. 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);
              }
        }