Esempio n. 1
0
 public CarrierTaskController(ITasksView view, string carrierName, IList users)
 {
     _view        = view;
     _tasks       = users;
     _carrierName = carrierName;
     view.SetController(this);
 }
 public void SetUp()
 {
     taskService = Substitute.For <ITaskService>();
     view        = Substitute.For <ITasksView>();
     controller  = Substitute.For <IApplicationController>();
     presenter   = new TasksPresenter(controller, view, taskService, backupService);
 }
Esempio n. 3
0
        /// <summary>
        /// Retrieves the TaskItems in the application and gives them to a ITasksView to display.
        /// </summary>
        /// <param name="view">
        /// Displays TaskItems in the application
        /// </param>
        public void ViewTasks(ITasksView view)
        {
            var uc = taskSchedulerApplication.NewViewTasksUseCase();

            ViewTasksOutput output = uc.Execute(new ViewTasksInput());

            if (output.Success)
            {
                /*
                 * iterate through TaskItems returned by the use case, convert them to models, then
                 * add them to the view to display
                 */
                foreach (TaskItemDTO taskDTO in output.TaskItems)
                {
                    //map the current taskDTOs NotificationFrequencyType enum to a string
                    string frequencyTypeStr = frequenctTypeStrMap[taskDTO.NotificationFrequencyType];

                    //convert the taskDTO's rgb color to a Windows brush
                    SolidColorBrush colorBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(255, taskDTO.R, taskDTO.G, taskDTO.B));

                    //create TaskItemModel from data of TaskItemDTO
                    TaskItemModel taskItemModel = new TaskItemModel()
                    {
                        Id                    = taskDTO.Id,
                        Title                 = taskDTO.Title,
                        Description           = taskDTO.Description,
                        FrequencyType         = frequencyTypeStr,
                        NotificationFrequency = taskDTO.CustomNotificationFrequency,
                        StartTime             = taskDTO.StartTime,
                        Color                 = colorBrush
                    };

                    view.TaskItems.Add(taskItemModel);
                }

                //subscribe the view to our TaskCreated event
                TaskCreated += view.TaskCreatedCallback;

                //Subscribe to the views Closing event, so we can unsubscribe the
                //view from the TaskCreated event
                view.Closing += (s, e) => { TaskCreated -= view.TaskCreatedCallback; };
            }
            else
            {
                //TODO: handle possible failure of use-case
            }
        }
Esempio n. 4
0
 public TaskController(ITaskRepository taskRepository, ILoadingView loadingView, ITasksView tasksView)
 {
     this.taskRepository = taskRepository;
     this.loadingView = loadingView;
     this.tasksView = tasksView;
 }