public async Task AddTask(TaskModel model)
        {
            ListTasks.Add(model);
            TasksUpdated?.Invoke(this, null);

            var newModel = new TaskVm();

            newModel.Id           = model.Id;
            newModel.AssignedToId = model.Member;
            newModel.IsComplete   = model.IsDone;
            newModel.Subject      = model.Text;

            var result = await Create(newModel.ToCreateTaskCommand());

            if (result != null)
            {
                var updatedList = (await GetAllTasks()).Payload;

                if (updatedList != null)
                {
                    tasks = updatedList;
                    TasksChanged?.Invoke(this, null);
                    return;
                }
                UpdateTaskFailed?.Invoke(this, "The creation was successful, but we can no longer get an updated list of members from the server.");
            }

            UpdateTaskFailed?.Invoke(this, "Unable to create record.");
        }
Example #2
0
 /**
  * Fonction qui crée une nouvelle tâche avec les paramètre rentré dans le formulaire
  *
  **/
 public void addSomething(object parameter)
 {
     if (NewTask.title == null || NewTask.content == null)
     {
         dialogErrorAdd();
     }
     else
     {
         ListTasks.Add(NewTask);
         NotifyPropertyChanged("ListTasks");
         NewTask = new Model.Tasks();
     }
 }
 public async void LoadTasks()
 {
     tasks = (await GetAllTasks()).Payload;
     //ListTasks = (List<TaskModel>)(await GetAllTasks()).Payload;
     foreach (var itm in tasks)
     {
         var data = new TaskModel();
         data.Id     = itm.Id;
         data.IsDone = itm.IsComplete;
         data.Member = itm.AssignedToId;
         data.Text   = itm.Subject;
         ListTasks.Add(data);
     }
     TasksChanged?.Invoke(this, null);
     return;
 }
Example #4
0
        /**
         * Fonction qui permet d'éditer une tâche de la liste
         **/

        public void EditTask(object parameter)
        {
            if (NewTask.title == "" || NewTask.title == null || NewTask.content == "" || NewTask.content == null)
            {
                dialogErrorAdd();
            }
            else
            {
                ListTasks.Add(NewTask);
                ListTasks.Remove(SelectedModel);
                NotifyPropertyChanged("ListTasks");
                NewTask        = new Model.Tasks();
                NewTaskTitle   = null;
                NewTaskContent = null;
                NewTaskDate    = DateTime.Today;
            }
        }