private void RadTreeView_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            string header = (e.OriginalSource as RadTreeViewItem).Header as string;

            switch (header)
            {
            case "Inputs":
                DataContext = new InputsViewModel(_studentService, _teacherService);
                break;

            case "Chart":
                DataContext = new ChartViewModel(_studentService);
                break;

            case "Spreadsheet":
                DataContext = new SpreadsheetViewModel();
                break;

            case "Grid":
                DataContext = new GridViewModel(_studentService);
                break;

            case "Scheduler":
                DataContext = new SchedulerViewModel(_appointmentService);
                break;

            case "Report":
                DataContext = new ReportViewModel();
                break;

            default:
                break;
            }
        }
Exemple #2
0
        public void GivenHasAScheduleOf(string scheduleName, Table table)
        {
            AppUsageStats.LocalHost = "http://localhost:3142";
            var mockServer = new Mock <IServer>();
            var mockshell  = new Mock <IShellViewModel>();

            mockshell.Setup(a => a.ActiveServer).Returns(mockServer.Object);
            mockshell.Setup(a => a.LocalhostServer).Returns(mockServer.Object);
            mockServer.Setup(a => a.GetServerVersion()).Returns("1.0.0.0");
            CustomContainer.Register(mockServer.Object);
            CustomContainer.Register(mockshell.Object);
            var mockPopupController = new Mock <IPopupController>();

            mockPopupController.Setup(controller => controller.ShowDeleteConfirmation(It.IsAny <string>())).Returns(MessageBoxResult.Yes);
            var serverRepository = ServerRepository.Instance;
            var server           = serverRepository.Source;

            CustomContainer.Register(serverRepository);
            var scheduler = new SchedulerViewModel(EventPublishers.Aggregator, new DirectoryObjectPickerDialog(), mockPopupController.Object, AsyncWorkerTests.CreateSynchronousAsyncWorker().Object, new Mock <IServer>().Object, a => new Mock <IServer>().Object);

            var resourceId = table.Rows[0]["ResourceId"];

            server.Connect();
            scheduler.ScheduledResourceModel = new ClientScheduledResourceModel(server, () => { });
            scheduler.CurrentEnvironment     = server;
            scheduler.CreateNewTask();
            scheduler.SelectedTask.Name                  = _scenarioContext["ScheduleName"].ToString();
            scheduler.SelectedTask.OldName               = "bob";
            scheduler.SelectedTask.UserName              = _scenarioContext["UserName"].ToString();
            scheduler.SelectedTask.Password              = _scenarioContext["Password"].ToString();
            scheduler.SelectedTask.WorkflowName          = _scenarioContext["WorkFlow"].ToString();
            scheduler.SelectedTask.ResourceId            = string.IsNullOrEmpty(resourceId) ? new Guid("acb75027-ddeb-47d7-814e-a54c37247ec1") : new Guid(resourceId);
            scheduler.SelectedTask.NumberOfHistoryToKeep = (int)_scenarioContext["HistoryCount"];
            scheduler.SelectedTask.Status                = (SchedulerStatus)_scenarioContext["TaskStatus"];
            scheduler.Errors.ClearErrors();
            var task = scheduler.SelectedTask;

            UpdateTrigger(task, table);

            var po       = new PrivateObject(scheduler.CurrentEnvironment);
            var mockAuth = new Mock <IAuthorizationService>();

            mockAuth.Setup(a => a.IsAuthorized(It.IsAny <AuthorizationContext>(), null)).Returns(true);
            po.SetFieldOrProperty("AuthorizationService", mockAuth.Object);
            _scenarioContext["Scheduler"] = scheduler;
            try
            {
                scheduler.SaveCommand.Execute("");
                if (scheduler.HasErrors)
                {
                    _scenarioContext["Error"] = scheduler.Error;
                    Console.WriteLine("Error creating schedule: " + scheduler.Error);
                }
            }
            catch (Exception e)
            {
                _scenarioContext["Error"] = e.Message;
                Console.WriteLine("Error creating schedule: " + e.Message);
            }
        }
        public SchedulerControl(SchedulerViewModel schedulerViewModel)
        {
            InitializeComponent();
            ApplyTemplate();

            DataContext = schedulerViewModel;
        }
        public async Task <IActionResult> Scheduler([FromRoute] int year, int month)
        {
            var user = await this.userManager.GetUserAsync(this.User);

            string userId = string.Empty;

            if (this.User.Identity.IsAuthenticated)
            {
                userId = user.Id;
            }

            if (month < 1)
            {
                year--;
                month = 12;
            }
            else if (month > 12)
            {
                year++;
                month = 1;
            }

            var events = new SchedulerViewModel
            {
                Events = this.workoutService.GetEvents(userId),
                Month  = month,
                Year   = year,
            };

            return(this.View(events));
        }
        public void WhenModelIsSet_IsValidIsUpdated()
        {
            var vm = new SchedulerViewModel();
            var model = new SchedulerDescriptorEditMock();
            var propertiesChanged = new List<string>();

            model.MakeValid();

            vm.PropertyChanged += (o, e) => propertiesChanged.Add(e.PropertyName);

            // Act.
            vm.Model = model;

            Assert.IsTrue(vm.IsValid);
            Assert.IsTrue(propertiesChanged.Any(p => p == "IsValid"));

            model = new SchedulerDescriptorEditMock();
            model.MakeInvalid();

            propertiesChanged.Clear();

            // Act.
            vm.Model = model;

            Assert.IsFalse(vm.IsValid);
            Assert.IsTrue(propertiesChanged.Any(p => p == "IsValid"));
        }
        public void TestNotifyPropertyChanged()
        {
            var vm = new SchedulerViewModel();

            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.Model);
            TestsHelper.TestPropertyWithNotifyPropertyChanged(vm, () => vm.SelectedSchedule);
        }
        public void DisplayedWeeksCaptionTest()
        {
            SchedulerViewModel      scheduler = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerMonthViewModel target    = new SchedulerMonthViewModel(scheduler, null);
            DateTime date = new DateTime(2010, 1, 1);

            target.Initialize(new DateTime(2010, 2, 1));

            try
            {
                target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

                PreparePropertyChangedTest();
                target.SetView(date);
                Assert.AreEqual(5, target.DisplayedWeeks, "DisplayedWeeks must be set 5.");
                Assert.IsTrue(NotifiedProperties.Contains("DisplayedWeeks"), "PropertyChanged event wasn't raised on property 'DisplayedWeeks' changing to 5.");

                PreparePropertyChangedTest();
                target.SetView(date.AddDays(40));
                Assert.AreEqual(4, target.DisplayedWeeks, "DisplayedWeeks must be set 4.");
                Assert.IsTrue(NotifiedProperties.Contains("DisplayedWeeks"), "PropertyChanged event wasn't raised on property 'DisplayedWeeks' changing to 4.");
            }
            finally
            {
                target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged);
            }
        }
        public void PropertiesTest()
        {
            var vm = new SchedulerViewModel();

            Assert.IsNotNull(vm.ScheduleList);

            TestsHelper.TestPublicPropertiesGetSet(vm);
        }
Exemple #9
0
 public ActionResult EditScheduler(SchedulerViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(View(model));
     }
     SchedulerRepository.Update(model.ToDto());
     return(RedirectToAction("scheduler-manager"));
 }
Exemple #10
0
        public void SchedulerViewModel_CreateNewTask_ServerDown_ShouldShowPopup()
        {
            //------------Setup for test--------------------------
            var popupController = new Mock <IPopupController>();

            popupController.Setup(c => c.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), "", false, true, false, false, false, false)).Returns(MessageBoxResult.OK).Verifiable();
            var env = new Mock <IServer>();

            env.Setup(a => a.IsConnected).Returns(true);
            var svr = new Mock <IServer>();

            svr.Setup(a => a.IsConnected).Returns(true);
            var mockConnection = new Mock <IEnvironmentConnection>();

            mockConnection.Setup(connection => connection.DisplayName).Returns("localhost");
            env.Setup(a => a.Connection).Returns(mockConnection.Object);
            var environmentRepository = new Mock <IServerRepository>();

            var environments = new List <IServer>();

            environmentRepository.Setup(e => e.All()).Returns(environments);
            CustomContainer.Register(environmentRepository.Object);
            var shellViewModel = new Mock <IShellViewModel>();

            CustomContainer.Register(shellViewModel.Object);
            CustomContainer.Register(new Mock <IExplorerTooltips>().Object);

            var schedulerViewModel = new SchedulerViewModel(new Mock <IEventAggregator>().Object, new Mock <DirectoryObjectPickerDialog>().Object, popupController.Object, new SynchronousAsyncWorker(), svr.Object, a => env.Object);
            var resources          = new ObservableCollection <IScheduledResource> {
                new ScheduledResource("bob", SchedulerStatus.Enabled, DateTime.MaxValue, new Mock <IScheduleTrigger>().Object, "c", Guid.NewGuid().ToString())
                {
                    NumberOfHistoryToKeep = 1
                }, new ScheduledResource("dave", SchedulerStatus.Enabled, DateTime.MaxValue, new Mock <IScheduleTrigger>().Object, "c", Guid.NewGuid().ToString())
            };

            schedulerViewModel.CurrentEnvironment = env.Object;
            var resourceModel = new Mock <IScheduledResourceModel>();

            resourceModel.Setup(c => c.ScheduledResources).Returns(resources);
            schedulerViewModel.ScheduledResourceModel = resourceModel.Object;
            schedulerViewModel.Server = svr.Object;
            if (Application.Current != null)
            {
                Application.Current.Shutdown();
            }
            //------------Execute Test---------------------------

            Assert.AreEqual(2, schedulerViewModel.TaskList.Count);

            env.Setup(a => a.IsConnected).Returns(false);

            schedulerViewModel.CurrentEnvironment = env.Object;

            schedulerViewModel.NewCommand.Execute(null);
            //------------Assert Results-------------------------
            popupController.Verify(a => a.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), "", false, true, false, false, false, false));
        }
Exemple #11
0
        public void SchedulerViewModel_CreateNewTask_ShouldAddTaskToListWithDefaultSettings_OnlyAllowOneDirtyTask()
        {
            //------------Setup for test--------------------------
            var popupController = new Mock <IPopupController>();
            var env             = new Mock <IServer>();

            env.Setup(a => a.IsConnected).Returns(true);
            var svr = new Mock <IServer>();

            svr.Setup(a => a.IsConnected).Returns(true);
            var environmentRepository = new Mock <IServerRepository>();

            var environments = new List <IServer>();

            environmentRepository.Setup(e => e.All()).Returns(environments);
            CustomContainer.Register(environmentRepository.Object);
            var shellViewModel = new Mock <IShellViewModel>();

            CustomContainer.Register(shellViewModel.Object);
            CustomContainer.Register(new Mock <IExplorerTooltips>().Object);

            var schedulerViewModel = new SchedulerViewModel(new Mock <IEventAggregator>().Object, new Mock <DirectoryObjectPickerDialog>().Object, popupController.Object, new SynchronousAsyncWorker(), svr.Object, a => env.Object);
            var resources          = new ObservableCollection <IScheduledResource> {
                new ScheduledResource("bob", SchedulerStatus.Enabled, DateTime.MaxValue, new Mock <IScheduleTrigger>().Object, "c", Guid.NewGuid().ToString())
                {
                    NumberOfHistoryToKeep = 1
                }, new ScheduledResource("dave", SchedulerStatus.Enabled, DateTime.MaxValue, new Mock <IScheduleTrigger>().Object, "c", Guid.NewGuid().ToString())
            };

            var resourceModel = new Mock <IScheduledResourceModel>();

            resourceModel.Setup(c => c.ScheduledResources).Returns(resources);
            schedulerViewModel.ScheduledResourceModel = resourceModel.Object;
            schedulerViewModel.Server = svr.Object;
            if (Application.Current != null)
            {
                Application.Current.Shutdown();
            }
            //------------Execute Test---------------------------

            Assert.AreEqual(2, schedulerViewModel.TaskList.Count);

            schedulerViewModel.NewCommand.Execute(null);
            Assert.AreEqual(3, schedulerViewModel.TaskList.Count);
            Assert.AreEqual("New Task1", schedulerViewModel.TaskList[1].Name);
            Assert.AreEqual("New Task1", schedulerViewModel.TaskList[1].OldName);
            Assert.IsTrue(schedulerViewModel.TaskList[1].IsDirty);
            Assert.AreEqual(SchedulerStatus.Enabled, schedulerViewModel.TaskList[1].Status);
            Assert.AreEqual(string.Empty, schedulerViewModel.TaskList[1].WorkflowName);
            Assert.AreEqual(schedulerViewModel.SelectedTask, schedulerViewModel.TaskList[1]);

            schedulerViewModel.NewCommand.Execute(null);
            //------------Assert Results-------------------------
            Assert.AreEqual(3, schedulerViewModel.TaskList.Count);
            popupController.Verify(a => a.Show("Please save currently edited Task(s) before creating a new one.", "Save before continuing", MessageBoxButton.OK, MessageBoxImage.Error, null, false, true, false, false, false, false));
        }
Exemple #12
0
        public ActionResult SchedulerManager()
        {
            var dtos = SchedulerRepository.GetSchedulers();
            var vms  = new List <SchedulerViewModel>();

            foreach (var dto in dtos)
            {
                vms.Add(SchedulerViewModel.Create(dto));
            }
            return(View(vms));
        }
Exemple #13
0
        public ActionResult EditScheduler(int id)
        {
            var dto = SchedulerRepository.GetScheduler(id);

            if (dto != null)
            {
                var vm = SchedulerViewModel.Create(dto);
                return(View(vm));
            }
            return(RedirectToAction("scheduler-manager"));
        }
Exemple #14
0
 public override void Init()
 {
     try
     {
         ViewModel = new SchedulerViewModel();
     }
     catch (Exception ex)
     {
         UtilityError.Write(ex);
     }
 }
        // GET: Event/Details/5
        public ActionResult Details(int id)
        {
            EventViewModel        eventSchedulerModel = new EventViewModel();
            List <EventViewModel> listEventScheduler  = new List <EventViewModel>();
            int idEvent    = 0;
            var eventt     = eventService.GetAll();
            var schedulers = schedulerService.GetAll();

            foreach (var i in eventt)
            {
                if (i.EventId == id)
                {
                    //idEvent = id;
                    eventSchedulerModel.Title       = i.Title;
                    eventSchedulerModel.DateString  = i.Start.ToString("MM/dd/yyyy hh:mm:ss");
                    eventSchedulerModel.Description = i.Description;
                    eventSchedulerModel.Address     = i.Address;
                    eventSchedulerModel.OrganizedBy = i.OrganizedBy;
                    foreach (Scheduler j in schedulers)
                    {
                        SchedulerViewModel se = new SchedulerViewModel()
                        {
                            Duration = "mmmm", ProgramName = "mmmmm"
                        };

                        /* se.Duration = j.Duration;
                         * se.ProgramName = j.ProgramName;*/
                        eventSchedulerModel.listScheduler.Add(se);
                    }

                    //listEventScheduler.Add(i.ListScheduler);

                    /* foreach(var j in i.ListScheduler)
                     * {
                     *   eventSchedulerModel.SchedulerModel.Duration = j.Duration;
                     *   eventSchedulerModel.SchedulerModel.ProgramName = j.ProgramName;
                     *
                     *
                     * }*/
                }
            }

            /* foreach(var i in schedulers)
             * {
             *   if (i.EventId == idEvent)
             *   {
             *       eventSchedulerModel.SchedulerModel.Duration = i.Duration;
             *       eventSchedulerModel.SchedulerModel.ProgramName = i.ProgramName;
             *   }
             * }*/

            return(View(eventSchedulerModel));
        }
Exemple #16
0
        public ActionResult CreateScheduler(SchedulerViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var dto = model.ToDto();
            var vm  = SchedulerViewModel.Create(dto);

            SchedulerRepository.Create(model.ToDto());
            return(RedirectToAction("scheduler-manager"));
        }
        public void CreateElementsTest()
        {
            SchedulerViewModel scheduler            = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerMonthViewModel_Accessor target = new SchedulerMonthViewModel_Accessor(scheduler, null);

            Assert.IsNull(target.Elements, "HeaderElements should be null.");

            target.InitializeModel(new DateTime(2010, 1, 1));
            target.CreateElements();

            Assert.IsNotNull(target.Elements, "HeaderElements should be initialized.");
        }
Exemple #18
0
 private void SchedulesButton_Click(object sender, RoutedEventArgs e)
 {
     if (mainViewModel.CurrentSeason?.Schedules != null)
     {
         var vm = (MainContent.Content?.GetType().Equals(typeof(SchedulerViewModel))).GetValueOrDefault() ? MainContent.Content as SchedulerViewModel : SchedulerViewModel;
         if (vm == null)
         {
             SchedulerViewModel = vm = new SchedulerViewModel();
         }
         MainContent.Content = vm;
         _ = vm.Load(mainViewModel.CurrentSeason.Model);
     }
 }
Exemple #19
0
        public void SetDisplayedDateCaptionTest()
        {
            SchedulerViewModel scheduler           = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerWeekViewModel_Accessor target = new SchedulerWeekViewModel_Accessor(scheduler, null, DisplayedDays.Week);

            target.InitializeModel(new DateTime(2010, 1, 1));

            Assert.IsNull(scheduler.DisplayedDate, "DisplayedDate should be null.");

            target.SetDisplayedDateCaption();

            Assert.IsNotNull(scheduler.DisplayedDate, "DisplayedDate should be set.");
        }
Exemple #20
0
        public void InitializeModelTest()
        {
            SchedulerViewModel scheduler           = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerWeekViewModel_Accessor target = new SchedulerWeekViewModel_Accessor(scheduler, null, DisplayedDays.Week);
            DateTime date = new DateTime(2010, 1, 1);

            Assert.IsNull(target.week, "week should be null.");

            target.InitializeModel(date);

            Assert.IsNotNull(target.week, "day should be initialized.");
            Assert.AreEqual(new DateTime(2009, 12, 28), target.week.Days[0].Date, "Date should be 12/28/2009.");
        }
        public void SetViewDateTest()
        {
            SchedulerViewModel scheduler            = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerMonthViewModel_Accessor target = new SchedulerMonthViewModel_Accessor(scheduler, null);
            DateTime date = new DateTime(2010, 1, 1);

            target.InitializeModel(date);

            Assert.AreEqual(new DateTime(2009, 12, 28), target.month.Weeks[0].Days[0].Date, "Date should be 12/28/2009.");

            target.SetViewDate(date.AddMonths(-1));

            Assert.AreEqual(new DateTime(2009, 11, 30), target.month.Weeks[0].Days[0].Date, "Date should be 11/30/2009.");
        }
Exemple #22
0
 public ActionResult Index()
 {
     if (User.Identity.IsAuthenticated)
     {
         var schedulerViewModel = new SchedulerViewModel()
         {
             AppointmentPlaces = _context.AppointmentPlaces.ToList(),
             Patients          = _context.Patients.ToList(),
             Therapists        = _context.Therapists.ToList()
         };
         return(View("LoggedInView", schedulerViewModel));
     }
     return(View());
 }
Exemple #23
0
        public void SetTodayTest()
        {
            SchedulerViewModel scheduler           = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerWeekViewModel_Accessor target = new SchedulerWeekViewModel_Accessor(scheduler, null, DisplayedDays.Week);
            DateTime date = new DateTime(2010, 1, 1);

            target.InitializeModel(date);

            Assert.IsTrue(target.week.Days[4].IsToday, "Today should be 1/1/2010.");

            target.SetViewDate(date.AddDays(-7));

            Assert.IsFalse(target.week.Days[4].IsToday, "Today should be 1/1/2010.");
        }
Exemple #24
0
        public void SetViewDateTest()
        {
            SchedulerViewModel scheduler           = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);
            SchedulerWeekViewModel_Accessor target = new SchedulerWeekViewModel_Accessor(scheduler, null, DisplayedDays.Week);
            DateTime date = new DateTime(2010, 1, 1);

            target.InitializeModel(date);

            Assert.AreEqual(new DateTime(2009, 12, 28), target.week.Days[0].Date, "Date should be 12/28/2009.");

            target.SetViewDate(date.AddDays(-7));

            Assert.AreEqual(new DateTime(2009, 12, 21), target.week.Days[0].Date, "Date should be 12/21/2009.");
        }
Exemple #25
0
        public IActionResult CustomerView(string id)
        {
            ViewData["CompanyId"] = id;
            var company = _context.Companies.Where(x => x.Id == id).FirstOrDefault();

            ViewData["Theme"] = company.Theme;
            var   home  = _context.HomePages.Where(x => x.CompanyId == company.Id).FirstOrDefault();
            About about = new About()
            {
                NavTag = "none"
            };
            Contact contact = new Contact()
            {
                NavTag = "none"
            };
            Scheduler sched = new Scheduler()
            {
                NavTag = "none"
            };

            if (company.About)
            {
                about = _context.AboutPages.Where(x => x.CompanyId == company.Id).FirstOrDefault();
            }
            if (company.Contact)
            {
                contact = _context.ContactPages.Where(x => x.CompanyId == company.Id).FirstOrDefault();
            }
            if (company.Scheduler)
            {
                sched = _context.SchedulePages.Where(x => x.CompanyId == company.Id).FirstOrDefault();
            }
            ViewData["homeNav"]      = home.NavTag;
            ViewData["aboutNav"]     = about.NavTag;
            ViewData["contactNav"]   = contact.NavTag;
            ViewData["schedulerNav"] = sched.NavTag;
            var cust   = _context.Customers.Where(x => x.UserId == User.Identity.GetUserId()).FirstOrDefault();
            var events = _context.Events.Where(x => x.CustomerId == User.Identity.GetUserId()).ToList();
            SchedulerViewModel ViewModel = new SchedulerViewModel()
            {
                Comp      = company,
                Events    = events,
                Customer  = cust,
                Scheduler = sched
            };

            return(View(ViewModel));
        }
        public ActionResult _Schedule(DateTime?StartDate, DateTime?EndDate)
        {
            SchedulerViewModel SchedulerViewModel = new SchedulerViewModel();

            try
            {
                SchedulerViewModel.StartDate = Convert.ToDateTime(StartDate);
                SchedulerViewModel.EndDate   = Convert.ToDateTime(EndDate);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(PartialView(SchedulerViewModel));
        }
Exemple #27
0
        public ActionResult Create(SchedulerViewModel svm)
        {
            Scheduler scheduler = new Scheduler();

            scheduler.Duration    = svm.Duration;
            scheduler.ProgramName = svm.ProgramName;
            // scheduler.Event = eventService.GetById(1);

            schedulerService.Add(scheduler);
            schedulerService.Commit();
            try
            {
                // TODO: Add insert logic here

                return(View());
            }
            catch
            {
                return(View());
            }
        }
        public void SetDisplayedDateTest()
        {
            SchedulerViewModel target = new SchedulerViewModel(null, new CultureInfo("en-US"), false, false);

            try
            {
                target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

                PreparePropertyChangedTest();
                target.SetDisplayedDate("TEST");
                Assert.IsTrue(NotifiedProperties.Contains("DisplayedDate"), "PropertyChanged event wasn't raised on property 'DisplayedDate' changing to TEST.");

                PreparePropertyChangedTest();
                target.SetDisplayedDate("TEST");
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'DisplayedDate' changing to TEST.");
            }
            finally
            {
                target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged);
            }
        }
        public SchedulerViewModel CreateSchedulerViewModel(CalendarPart calendar)
        {
            var eventCategories = _categoryService
                                  .GetEventCategoriesByCalendar(calendar.ContentItem);

            var data = new SchedulerViewModel
            {
                Identifier      = calendar.Identifier,
                Title           = calendar.Title,
                Summary         = calendar.ShortDescription,
                EventCategories = eventCategories.Select(x => new CategoryEntry
                {
                    Identifier  = x.Identifier,
                    Name        = x.CategoryName,
                    Description = x.Description,
                    IsChecked   = calendar.Categories.Any(cat => cat.Id == x.Id),
                }).ToList(),
            };

            return(data);
        }
Exemple #30
0
        public void GivenHasAScheduleOf(string scheduleName, Table table)
        {
            AppSettings.LocalHost = "http://localhost:3142";
            SchedulerViewModel scheduler        = new SchedulerViewModel(EventPublishers.Aggregator, new DirectoryObjectPickerDialog(), new PopupController(), new TestAsyncWorker(), new Mock <IConnectControlViewModel>().Object);
            IEnvironmentModel  environmentModel = EnvironmentRepository.Instance.Source;

            environmentModel.Connect();
            scheduler.ScheduledResourceModel = new ClientScheduledResourceModel(environmentModel);
            scheduler.CurrentEnvironment     = environmentModel;
            scheduler.CreateNewTask();
            scheduler.SelectedTask.Name                  = ScenarioContext.Current["ScheduleName"].ToString();
            scheduler.SelectedTask.OldName               = "bob";
            scheduler.SelectedTask.UserName              = ScenarioContext.Current["UserName"].ToString();
            scheduler.SelectedTask.Password              = ScenarioContext.Current["Password"].ToString();
            scheduler.SelectedTask.WorkflowName          = ScenarioContext.Current["WorkFlow"].ToString();
            scheduler.SelectedTask.NumberOfHistoryToKeep = (int)ScenarioContext.Current["HistoryCount"];
            scheduler.SelectedTask.Status                = (SchedulerStatus)ScenarioContext.Current["TaskStatus"];
            scheduler.Errors.ClearErrors();
            var task = scheduler.SelectedTask;

            UpdateTrigger(task, table);

            PrivateObject po       = new PrivateObject(scheduler.CurrentEnvironment);
            var           mockAuth = new Mock <IAuthorizationService>();

            mockAuth.Setup(a => a.IsAuthorized(It.IsAny <AuthorizationContext>(), null)).Returns(true);
            po.SetFieldOrProperty("AuthorizationService", mockAuth.Object);
            ScenarioContext.Current["Scheduler"] = scheduler;
            try
            {
                scheduler.SaveCommand.Execute("");
            }
            catch (Exception e)
            {
                ScenarioContext.Current["Error"] = e.Message;
            }
        }
        public IActionResult Index()
        {
            var model = new SchedulerViewModel
            {
                Title = "Patient Scheduling",
                EnableIntervalConfig = IsTrustAdmin || IsPharmixAdmin
            };

            var depts = new List <Department>();

            if (IsPharmixAdmin || IsTrustAdmin)
            {
                var trustId = IsPharmixAdmin ? HttpContext.Session.GetInt32("TrustID") ?? 1 : trustService.GetTrustIdByUser(CurrentUserName);
                depts = trustService.GetAllDepartmentsByTrustId(trustId).ToList();
            }
            else
            {
                depts = trustService.GetUserDepartments(GetCurrentUserId()).ToList();
            }

            model.Departments = new SelectList(depts, "DepartmentId", "DepartmentName");

            return(View(model));
        }
        public void OnSaved_Test()
        {
            var model = new SchedulerDescriptorEditMock();
            var schedule1 = DataPortal.CreateChild<ScheduleEdit>();
            var schedule2 = DataPortal.CreateChild<ScheduleEdit>();

            model.ScheduleList.Add(schedule1);
            model.ScheduleList.Add(schedule2);

            var vm = new SchedulerViewModel();
            var scheduleViewModelMocks = new List<IScheduleViewModel>();

            vm.ScheduleViewModelFactory = new ExportFactory<IScheduleViewModel>(
                () =>
                    {
                        var vmMock = Mock.Create<IScheduleViewModel>();

                        scheduleViewModelMocks.Add(vmMock);
                        return new Tuple<IScheduleViewModel, Action>(vmMock, () => { });
                    });

            vm.Initialize(model);

            var newModel = new SchedulerDescriptorEditMock();

            newModel.ScheduleList.Add(DataPortal.CreateChild<ScheduleEdit>());
            newModel.ScheduleList.Add(DataPortal.CreateChild<ScheduleEdit>());
            newModel.ScheduleList.Add(DataPortal.CreateChild<ScheduleEdit>());

            scheduleViewModelMocks.Clear();

            vm.OnSaved(newModel);

            Assert.AreEqual(3, vm.ScheduleList.Count);
            Assert.IsTrue(scheduleViewModelMocks.Select(mock => mock).SequenceEqual(vm.ScheduleList));

            for (var i = 0; i < scheduleViewModelMocks.Count; i++)
            {
                var i1 = i;
                Mock.Assert(() => scheduleViewModelMocks[i1].Initialize(newModel.ScheduleList[i1]));
            }
        }
        public void RemoveScheduleCommand_Test()
        {
            var model = new SchedulerDescriptorEditMock();

            model.ScheduleList.Add(DataPortal.CreateChild<ScheduleEdit>());
            model.ScheduleList.Add(DataPortal.CreateChild<ScheduleEdit>());

            var vm = new SchedulerViewModel
                         {
                             ScheduleViewModelFactory = new ExportFactory<IScheduleViewModel>(
                                 () =>
                                     {
                                         var vmMock = Mock.Create<IScheduleViewModel>(Behavior.CallOriginal);

                                         Mock.Arrange(() => vmMock.Initialize(Arg.IsAny<ScheduleEdit>())).DoInstead<ScheduleEdit>(s => Mock.Arrange(() => vmMock.Model).Returns(s));

                                         return new Tuple<IScheduleViewModel, Action>(vmMock, () => { });
                                     })
                         };

            var popupBuilderMock = Mock.Create<PopupBuilder>(Behavior.CallOriginal);

            Action onOk = null;

            Mock.Arrange(() => popupBuilderMock.Show(Arg.IsAny<Action>(), Arg.IsAny<Func<bool>>())).Returns<Action, Func<bool>>(
                (ok, cancel) =>
                    {
                        onOk = ok;
                        return popupBuilderMock;
                    });
            
            var popupFactoryMock = Mock.Create<PopupFactory>(Behavior.CallOriginal);

            Mock.Arrange(() => popupFactoryMock.Popup()).Returns(popupBuilderMock);

            vm.ThePopupFactory = popupFactoryMock;

            vm.Initialize(model);

            vm.SelectedSchedule = null;

            Assert.IsFalse(vm.RemoveScheduleCommand.CanExecute(new object()));

            var scheduleToRemove = vm.ScheduleList.First();
            vm.SelectedSchedule = scheduleToRemove;

            Assert.IsTrue(vm.RemoveScheduleCommand.CanExecute(new object()));

            vm.RemoveScheduleCommand.Execute(new object());

            Assert.IsNotNull(onOk);

            onOk();
            Assert.AreEqual(1, vm.ScheduleList.Count);
            Assert.AreEqual(1, model.ScheduleList.Count);
            Assert.AreSame(vm.ScheduleList[0], vm.SelectedSchedule);
            Assert.IsFalse(vm.ScheduleList.Contains(scheduleToRemove));
        }
Exemple #34
0
 public SchedulerPage()
 {
     InitializeComponent();
     _viewModel     = new SchedulerViewModel();
     BindingContext = _viewModel;
 }
 public ScheduleTaskManagerStub(IServer server, SchedulerViewModel schedulerViewModel, Task <IResourcePickerDialog> getResourcePicker)
     : base(server, schedulerViewModel, getResourcePicker)
 {
 }
 internal MySchedulerTaskManager(IServer server, SchedulerViewModel vm, Task <IResourcePickerDialog> resourcePickerDialog, IShellViewModel shellVm)
     : base(vm, resourcePickerDialog)
 {
 }
        public void AddScheduleCommand_Test()
        {
            var model = new SchedulerDescriptorEditMock();
            var vm = new SchedulerViewModel();
            var scheduleViewModelMocks = new List<IScheduleViewModel>();

            vm.ScheduleViewModelFactory = new ExportFactory<IScheduleViewModel>(
                () =>
                    {
                        var vmMock = Mock.Create<IScheduleViewModel>();

                        scheduleViewModelMocks.Add(vmMock);
                        return new Tuple<IScheduleViewModel, Action>(vmMock, () => { });
                    });

            vm.Initialize(model);

            Assert.AreEqual(0, model.ScheduleList.Count);
            Assert.AreEqual(0, vm.ScheduleList.Count);

            vm.AddScheduleCommand.Execute(new object());

            Assert.AreEqual(1, model.ScheduleList.Count);
            Assert.AreEqual(1, vm.ScheduleList.Count);

            Mock.Assert(() => scheduleViewModelMocks[0].Initialize(model.ScheduleList[0]));
        }