コード例 #1
0
        public void TimeSlotViewModel_DisplayTime_Reflects_Initialized_State()
        {
            var timeSlot  = GetBasicTimeSlot();
            var viewModel = new TimeSlotViewModel(timeSlot);

            Assert.AreEqual("00:05:00", viewModel.DisplayTime);
        }
コード例 #2
0
ファイル: DoctorController.cs プロジェクト: skgtrx/CMS
        public ActionResult PopulateTimeSlots(TimeSlotViewModel model)//int id)
        {
            DateTime date = DateTime.Now;

            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            DoctorScheduleViewModel  doctorScheduleViewModel  = new DoctorScheduleViewModel();
            DoctorScheduleManagement doctorScheduleManagement = new DoctorScheduleManagement();

            doctorScheduleViewModel.From           = doctorScheduleManagement.GetTimeSlots();
            doctorScheduleViewModel.SelectedFromId = model.SelectedSlot;
            if (model.SelectedSlot == 0)
            {
                doctorScheduleViewModel.PreviousFromScheduleTime = doctorScheduleManagement.GetExistingFromSchedule((int)Session["userId"], model.Date);
                doctorScheduleViewModel.PreviousToScheduleTime   = null;
            }
            else
            {
                doctorScheduleViewModel.PreviousFromScheduleTime = null;
                doctorScheduleViewModel.PreviousToScheduleTime   = doctorScheduleManagement.GetExistingToSchedule((int)Session["userId"], model.Date);
            }
            return(View(doctorScheduleViewModel));
        }
コード例 #3
0
 public UserReservationsPage()
 {
     InitializeComponent();
     this.timeSlotViewModel = new TimeSlotViewModel();
     this.accountViewModel  = new AccountViewModel();
     BindingContext         = this.timeSlotViewModel;
 }
コード例 #4
0
        public void TimeSlotViewModel_AssignedSeconds_Reflects_Initialized_State()
        {
            var timeSlot  = GetBasicTimeSlot();
            var viewModel = new TimeSlotViewModel(timeSlot);

            Assert.AreEqual(timeSlot.AssignedSeconds, viewModel.AssignedSeconds);
        }
コード例 #5
0
 public ChangeReservationPage()
 {
     InitializeComponent();
     time = timeSlotViewModel.timeSlot;
     this.timeSlotViewModel = new TimeSlotViewModel();
     BindingContext         = this.timeSlotViewModel;
 }
コード例 #6
0
        public void TimeSlotViewModel_Title_Reflects_Initialized_State()
        {
            var timeSlot  = GetBasicTimeSlot();
            var viewModel = new TimeSlotViewModel(timeSlot);

            Assert.AreEqual(timeSlot.Title, viewModel.Title);
        }
コード例 #7
0
        public void TimeSlotViewModel_TimeSlots_Are_Populated_When_Initialized()
        {
            TimeSlotViewModel viewModel = new TimeSlotViewModel(GetBasicTimeSlot());

            Assert.AreEqual(3, viewModel.Exercises.Count);
            Assert.That(viewModel.Exercises[0], Is.TypeOf <TimeSlotExerciseViewModel>());
        }
コード例 #8
0
 public ChangeReservationPage(TimeSlotViewModel timeSlotViewModel, AccountViewModel accountViewModel)
 {
     InitializeComponent();
     time = timeSlotViewModel.timeSlot;
     this.timeSlotViewModel = timeSlotViewModel;
     this.accountViewModel  = accountViewModel;
     BindingContext         = this.accountViewModel;
     BindingContext         = timeSlotViewModel;
 }
コード例 #9
0
        public void TimeSlotExerciseViewModel_Initialized_With_No_TimeSlotExercise_Throws_Exception()
        {
            PracticeRoutineTimeSlot timeSlot          = EntityFactory.GetSingleTimeSlot();
            TimeSlotViewModel       timeSlotViewModel = new TimeSlotViewModel(timeSlot);

            TestDelegate proc = () => new TimeSlotExerciseViewModel(null, timeSlotViewModel);

            Assert.That(proc, Throws.TypeOf <ArgumentNullException>());
        }
コード例 #10
0
        public void TimeSlotExerciseViewModel_Title_Is_Populated_When_Initialized()
        {
            PracticeRoutineTimeSlot timeSlot          = EntityFactory.GetSingleTimeSlot();
            TimeSlotViewModel       timeSlotViewModel = new TimeSlotViewModel(timeSlot);
            TimeSlotExercise        timeSlotExercise  = EntityFactory.GetTimeSlotExercise();

            TimeSlotExerciseViewModel viewModel = new TimeSlotExerciseViewModel(timeSlotExercise, timeSlotViewModel);

            Assert.AreEqual("Existing Exercise", viewModel.Title);
        }
コード例 #11
0
        public IActionResult Post([FromBody] TimeSlotViewModel value)
        {
            //ignore the end date for now
            value.EndDatetime = value.BeginDatetime.AddHours(1).AddMinutes(-1);


            var added = _mapper.Map <TimeSlotViewModel, TimeSlot>(value);

            return(StatusCode((int)HttpStatusCode.Created, _timeSlots.Add(added)));
        }
コード例 #12
0
        public void TimeSlotExerciseViewModel_Exposes_TimeSlotExercise()
        {
            PracticeRoutineTimeSlot timeSlot          = EntityFactory.GetSingleTimeSlot();
            TimeSlotViewModel       timeSlotViewModel = new TimeSlotViewModel(timeSlot);
            TimeSlotExercise        timeSlotExercise  = EntityFactory.GetTimeSlotExercise();

            TimeSlotExerciseViewModel viewModel = new TimeSlotExerciseViewModel(timeSlotExercise, timeSlotViewModel);

            Assert.IsNotNull(viewModel.TimeSlotExercise);
            Assert.AreEqual(timeSlot[0].Title, viewModel.TimeSlotExercise.Title);
        }
コード例 #13
0
        public IActionResult Put(int id, [FromBody] TimeSlotViewModel value)
        {
            //ignore the end date for now
            value.EndDatetime = value.BeginDatetime.AddHours(1).AddMinutes(-1);

            var updated  = _mapper.Map <TimeSlotViewModel, TimeSlot>(value);
            var response = _timeSlots.Update(id, updated);


            return(StatusCode((int)HttpStatusCode.OK, _mapper.Map <TimeSlot, TimeSlotViewModel>(response)));
        }
コード例 #14
0
        public void TimeSlotViewModel_DecrementtMinutes_Reflects_On_Domain()
        {
            var timeSlot = GetBasicTimeSlot();
            TimeSlotViewModel viewModel = new TimeSlotViewModel(timeSlot);

            var timeBefore = timeSlot.AssignedSeconds;

            viewModel.DecrementMinutesCommand.Execute(null);
            var timeAfter = timeSlot.AssignedSeconds;

            Assert.AreEqual(timeAfter, timeBefore - 60);
        }
コード例 #15
0
        public void TimeSlotViewModel_Edit_TimeSlotViewModel_Raises_ItemChanged()
        {
            var listChanged = false;
            TimeSlotViewModel         viewModel   = new TimeSlotViewModel(GetBasicTimeSlot());
            TimeSlotExerciseViewModel anyExercise = viewModel.Exercises[0];

            viewModel.Exercises.ListChanged += (s, e) => listChanged = true;

            anyExercise.FrequencyWeighting = 1;

            Assert.IsTrue(listChanged);
        }
コード例 #16
0
        public void TimeSlotViewModel_DecrementtMinutes_Is_Less_Than_Zero_Is_Zero()
        {
            var timeSlot = GetBasicTimeSlot();

            timeSlot.AssignedSeconds = 60;

            TimeSlotViewModel viewModel = new TimeSlotViewModel(timeSlot);

            viewModel.DecrementMinutesCommand.Execute(null);
            viewModel.DecrementMinutesCommand.Execute(null);

            Assert.AreEqual(0, timeSlot.AssignedSeconds);
        }
コード例 #17
0
        public void TimeSlotViewModel_Remove_TimeSlotViewModel_Raises_ItemChanged()
        {
            var listChanged = false;
            TimeSlotViewModel         viewModel = new TimeSlotViewModel(GetBasicTimeSlot());
            TimeSlotExerciseViewModel first     = viewModel.Exercises[0];

            viewModel.Exercises.ListChanged += (s, e) => listChanged = true;

            viewModel.SelectedExercise = first;

            viewModel.Exercises.Remove(first);

            Assert.IsTrue(listChanged);
        }
コード例 #18
0
        public void TimeSlotViewModel_Remove_TimeSlot_Actually_Removes_TimeSlot()
        {
            TimeSlotViewModel         viewModel = new TimeSlotViewModel(GetBasicTimeSlot());
            TimeSlotExerciseViewModel first     = viewModel.Exercises[0];

            viewModel.SelectedExercise = first;

            var beforeCount = viewModel.Exercises.Count;

            viewModel.Exercises.Remove(first);
            var afterCount = viewModel.Exercises.Count;

            Assert.AreEqual(beforeCount - 1, afterCount);
        }
コード例 #19
0
        public async Task <ApiResult <List <TimeSlotViewModel> > > GetAvailableSlots()
        {
            List <TimeSlotViewModel> TimeSlot = new List <TimeSlotViewModel>();
            TimeSlotViewModel        timeSlotViewModel;
            List <TimeSlots>         slots;
            TimeSlots    timeSlots;
            SqlParameter NoOfDays = new SqlParameter("@NoOfDays", System.Data.SqlDbType.VarChar)
            {
                Value = 10
            };
            var    data = _context.ExecuteStoreProcedure("usp_GetAvailableSlots", NoOfDays);
            string Date = "";

            for (int i = 0; i < data.Tables[0].Rows.Count; i++)
            {
                if (Date != data.Tables[0].Rows[i]["FullDate"].ToString())
                {
                    Date = data.Tables[0].Rows[i]["FullDate"].ToString();
                    timeSlotViewModel            = new TimeSlotViewModel();
                    timeSlotViewModel.Key        = i;
                    timeSlotViewModel.FullDate   = data.Tables[0].Rows[i]["FullDate"].ToString();
                    timeSlotViewModel.Date       = data.Tables[0].Rows[i]["Date"].ToString();
                    timeSlotViewModel.Day        = data.Tables[0].Rows[i]["Day"].ToString();
                    timeSlotViewModel.Month      = data.Tables[0].Rows[i]["Month"].ToString();
                    timeSlotViewModel.ShortMonth = data.Tables[0].Rows[i]["ShortMonth"].ToString();

                    slots = new List <TimeSlots>();
                    for (int j = 0; j < data.Tables[0].Rows.Count; j++)
                    {
                        if (Date == data.Tables[0].Rows[j]["FullDate"].ToString())
                        {
                            timeSlots                 = new TimeSlots();
                            timeSlots.SlotId          = Convert.ToInt32(data.Tables[0].Rows[j]["SlotId"].ToString());
                            timeSlots.Label           = data.Tables[0].Rows[j]["Label"].ToString();
                            timeSlots.Icon            = data.Tables[0].Rows[j]["Icon"].ToString();
                            timeSlots.SlotRange       = data.Tables[0].Rows[j]["SlotRange"].ToString();
                            timeSlots.IsSlotAvailable = true;
                            slots.Add(timeSlots);
                        }
                    }

                    timeSlotViewModel.timeSlots = slots;
                    TimeSlot.Add(timeSlotViewModel);
                }
            }

            return(TimeSlot == null
                    ? new ApiResult <List <TimeSlotViewModel> >(new ApiResultCode(ApiResultType.Error, 1, "No data in given request"))
                    : new ApiResult <List <TimeSlotViewModel> >(new ApiResultCode(ApiResultType.Success), TimeSlot));
        }
コード例 #20
0
ファイル: PatientController.cs プロジェクト: skgtrx/CMS
        public ActionResult PopulateTimeSlot(TimeSlotViewModel model)
        {
            if (Session["userId"] == null)
            {
                return(Redirect("~"));
            }
            //model.Date = (DateTime)TempData["SelectedDateForAppointment"];
            ScheduleBasedAppointmentManagement appointmentManagement = new ScheduleBasedAppointmentManagement();
            var doctorAvailability = appointmentManagement.GetAvailability(model.DoctorId, model.Date);

            model.FromSlot  = doctorAvailability.FromTime;
            model.ToSlot    = doctorAvailability.ToTime;
            model.TimeSlots = new DoctorsData().GetDoctorAvailableTimeSlots(model.DoctorId, model.Date);
            model.RemoveExistingAppointmentSlots((int)Session["userId"], model.Date);
            return(View(model));
        }
コード例 #21
0
ファイル: DoctorController.cs プロジェクト: skgtrx/CMS
        public ActionResult PopulateToTimeSlots(TimeSlotViewModel model)
        {
            DoctorScheduleViewModel  doctorScheduleViewModel  = new DoctorScheduleViewModel();
            DoctorScheduleManagement doctorScheduleManagement = new DoctorScheduleManagement();

            doctorScheduleViewModel.From = doctorScheduleManagement.GetTimeSlots();
            doctorScheduleViewModel.PreviousToScheduleTime   = doctorScheduleManagement.GetExistingToSchedule((int)Session["userId"], model.Date);
            doctorScheduleViewModel.PreviousFromScheduleTime = doctorScheduleManagement.GetExistingFromSchedule((int)Session["userId"], model.Date);
            if (doctorScheduleViewModel.PreviousToScheduleTime != null)
            {
                return(View(doctorScheduleViewModel));
            }
            else
            {
                return(null);
            }
        }
コード例 #22
0
        public void TimeSlotViewModel_AssignedSeconds_Set_Fires_PropertyChanged_For_DisplayTime()
        {
            var fired     = false;
            var timeSlot  = GetBasicTimeSlot();
            var viewModel = new TimeSlotViewModel(timeSlot);

            viewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "DisplayTime")
                {
                    fired = true;
                }
            };
            viewModel.AssignedSeconds = 600;

            Assert.IsTrue(fired);
        }
コード例 #23
0
        public void TimeSlotViewModel_Title_Set_Fires_PropertyChanged()
        {
            var fired     = false;
            var timeSlot  = GetBasicTimeSlot();
            var viewModel = new TimeSlotViewModel(timeSlot);

            viewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "Title")
                {
                    fired = true;
                }
            };
            viewModel.Title = "Modified Title";

            Assert.IsTrue(fired);
        }
コード例 #24
0
        public void PracticeRoutineEditViewModel_Edit_TimeSlotViewModel_Raises_ItemChanged()
        {
            var listChanged = false;

            var dialogService   = new Mock <IDialogViewService>();
            var practiceRoutine = EntityFactory.GetBasicPracticeRoutine();
            var viewModel       = new PracticeRoutineEditViewModel(dialogService.Object);

            viewModel.StartEdit(practiceRoutine);

            TimeSlotViewModel anyTimeSlot = viewModel.TimeSlots[0];

            viewModel.TimeSlots.ListChanged += (s, e) => listChanged = true;

            anyTimeSlot.Title = "Some Arbitrary New Title";

            Assert.IsTrue(listChanged);
        }
コード例 #25
0
        public async Task <IActionResult> Index()
        {
            var currentUser = await _userManager.GetUserAsync(User);

            if (currentUser == null)
            {
                return(Challenge());
            }

            var timeSlots = await _timeSlotService.GetAllTimeSlotsAsync();

            var viewModel = new TimeSlotViewModel
            {
                TimeSlotModels = timeSlots
            };

            return(View(viewModel));
        }
コード例 #26
0
        public AddWorkView()
        {
            InitializeComponent();
            _viewModel         = new WorkViewModel();
            _timeSlotViewModel = new TimeSlotViewModel();
            var x = _viewModel.LoadData();

            /*string[] days = new string[] { "Mon", "Tue", "Wed", "Thu", "Fri" };
             * //for (int i = 0; i < days.Length; i++)
             * //{
             * //    days[i] =
             * //}
             *
             *
             * //For day : - 9 ?
             * // # of days : - 5 ?
             * // TOT = 9*5 = 45
             * _timeSlotEntities = new List<TimeSlotEntity>();
             * int startTime = 8;
             * int currentDate = 0;
             * int endTime = 17;
             * for (int i = 1; i < 46; i++)
             * {
             *  if (startTime == endTime)
             *  {
             *      startTime = 8;
             *      currentDate++;
             *  }
             *
             *  _timeSlotEntities.Add(
             *      new TimeSlotEntity { ID = i, TimeSlot = $"{startTime}-{++startTime}", Day = days[currentDate] }
             *      );
             * }
             *
             * //timeSlotEntity = new TimeSlotEntity(2, "8-9", "tue");
             * //_timeSlotViewModel.SaveTimeSlotsData(timeSlotEntity);
             *
             * /*foreach (TimeSlotEntity t in _timeSlotEntities)
             * {
             *  _timeSlotViewModel.SaveTimeSlotsData(t);
             * }*/
        }
コード例 #27
0
        public void TimeSlotExerciseViewModel_FrequencyWeighting_Set_Fires_PropertyChanged()
        {
            var fired = false;
            PracticeRoutineTimeSlot timeSlot          = EntityFactory.GetSingleTimeSlot();
            TimeSlotViewModel       timeSlotViewModel = new TimeSlotViewModel(timeSlot);
            TimeSlotExercise        timeSlotExercise  = EntityFactory.GetTimeSlotExercise();

            TimeSlotExerciseViewModel viewModel = new TimeSlotExerciseViewModel(timeSlotExercise, timeSlotViewModel);

            viewModel.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "FrequencyWeighting")
                {
                    fired = true;
                }
            };
            viewModel.FrequencyWeighting = 4;

            Assert.IsTrue(fired);
        }
コード例 #28
0
        public void PracticeRoutineEditViewModel_Remove_TimeSlot_Removes_TimeSlot()
        {
            var dialogService = new Mock <IDialogViewService>();

            dialogService.Setup(ds => ds.YesNoPrompt(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            var practiceRoutine = EntityFactory.GetBasicPracticeRoutine();
            var viewModel       = new PracticeRoutineEditViewModel(dialogService.Object);

            viewModel.StartEdit(practiceRoutine);

            TimeSlotViewModel firstTimeSlot = viewModel.TimeSlots[0];

            viewModel.SelectedItem = firstTimeSlot;

            var beforeCount = viewModel.TimeSlots.Count;

            viewModel.DeleteCommand.Execute(null);
            var afterCount = viewModel.TimeSlots.Count;

            Assert.AreEqual(beforeCount - 1, afterCount);
        }
コード例 #29
0
        public void PracticeRoutineEditViewModel_Remove_TimeSlotViewModel_Raises_ItemChanged()
        {
            var listChanged = false;

            var dialogService = new Mock <IDialogViewService>();

            dialogService.Setup(ds => ds.YesNoPrompt(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            var practiceRoutine = EntityFactory.GetBasicPracticeRoutine();
            var viewModel       = new PracticeRoutineEditViewModel(dialogService.Object);

            viewModel.StartEdit(practiceRoutine);

            TimeSlotViewModel firstTimeSlot = viewModel.TimeSlots[0];

            viewModel.TimeSlots.ListChanged += (s, e) => listChanged = true;

            viewModel.SelectedItem = firstTimeSlot;

            viewModel.DeleteCommand.Execute(null);

            Assert.IsTrue(listChanged);
        }
コード例 #30
0
 public async Task <IActionResult> AddDeliveryHour(Guid id, TimeSlotViewModel deliveryHour, CancellationToken token)
 {
     return(RedirectToAction("Edit", new { id }));
 }