예제 #1
0
        public async void StartAppointmentShouldChangeTheStatusToHappening()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var appointmentsRepository  = new EfDeletableEntityRepository <Appointment>(new ApplicationDbContext(options.Options));
            var notificationsRepository = new EfDeletableEntityRepository <Notification>(new ApplicationDbContext(options.Options));

            var appointmentsService = new AppointmentsService(notificationsRepository, appointmentsRepository);

            var appointment = new Appointment
            {
                Status      = AppointmentStatus.Unprocessed,
                Date        = DateTime.UtcNow,
                StartTime   = DateTime.UtcNow,
                EndTime     = DateTime.UtcNow.AddMinutes(5),
                DogsitterId = "123",
                OwnerId     = "321",
            };

            await appointmentsService.CreateNewAppointment(appointment);

            await appointmentsService.StartAppointment(appointment.Id);

            Assert.Equal(AppointmentStatus.Happening.ToString(), appointmentsService.GetAppointment(appointment.Id).Status.ToString());
        }
        public AppointmentsController()
        {
            UnitOfWork unitOfWork = new UnitOfWork();

            this.appointmentsService = new AppointmentsService(new ModelStateWrapper(this.ModelState), unitOfWork);
            this.activitiesService   = new ActivitiesService(new ModelStateWrapper(this.ModelState), unitOfWork);
        }
예제 #3
0
        public async Task CheckGettingAppointmentsForTodayAsync()
        {
            ApplicationDbContext db = GetDb();

            var repository = new EfDeletableEntityRepository <Appointment>(db);
            var service    = new AppointmentsService(
                repository,
                this.usersService.Object,
                this.cardsService.Object,
                this.proceduresService.Object,
                this.categoriesService.Object);

            await this.PrepareAppointmentsAsync(service);

            var appointments = await service.GetAllAppointmentsForTodayAsync <TestAppointmentModel>();

            var appointmentsExpected = await repository
                                       .All()
                                       .Where(a => a.DateTime == DateTime.UtcNow.Date)
                                       .To <TestAppointmentModel>()
                                       .ToListAsync();

            Assert.Empty(appointments);
            appointments.SequenceEqual(appointmentsExpected);
        }
예제 #4
0
        public async void EndAppointmentShouldChangeTheStatusToProcessed(AppointmentStatus status)
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var appointmentsRepository  = new EfDeletableEntityRepository <Appointment>(new ApplicationDbContext(options.Options));
            var notificationsRepository = new EfDeletableEntityRepository <Notification>(new ApplicationDbContext(options.Options));

            var appointmentsService = new AppointmentsService(notificationsRepository, appointmentsRepository);

            var appointment = new Appointment
            {
                Status    = status,
                Date      = DateTime.UtcNow,
                StartTime = DateTime.UtcNow,
                EndTime   = DateTime.UtcNow.AddMinutes(5),
                Dogsitter = new Dogsitter
                {
                    WageRate = 10,
                },
                Owner = new Owner(),
            };

            await appointmentsService.CreateNewAppointment(appointment);

            await appointmentsService.EndAppointment(appointment.Id);

            Assert.Equal(AppointmentStatus.Processed.ToString(), appointmentsService.GetAppointment(appointment.Id).Status.ToString());
        }
        public async Task AddAppointmentShouldReturnNull(string clientId, string trainerId)
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;
            var db = new ApplicationDbContext(options);
            var appointmentsRepository = new EfDeletableEntityRepository <Appointment>(db);
            var usersRepository        = new EfDeletableEntityRepository <ApplicationUser>(db);
            var notificationsService   = new Mock <INotificationsService>();

            var service = new AppointmentsService(
                appointmentsRepository,
                usersRepository,
                notificationsService.Object);

            var inputModel = new AddAppointmentInputModel()
            {
                StartTime  = DateTime.UtcNow,
                EndTime    = DateTime.UtcNow.AddDays(2),
                ClientId   = clientId,
                TrainerId  = trainerId,
                IsApproved = true,
                Notes      = null,
                Type       = AppointmentType.Consultation,
            };

            var result = await service.AddAppoinmentAsync(inputModel);

            Assert.Null(result);
        }
        private void AddAppointment_OnClick(object sender, RoutedEventArgs e)
        {
            var selectedAppointment = this.AvailableAppointments.SelectedItem as AvailableAppointmentRowDto;
            var selectedSpecialist  = this.Specialists.SelectedIndex;


            if (selectedSpecialist < 0 || selectedAppointment == null)
            {
                return;
            }

            var specialist = this._currentSpecialists[selectedSpecialist];

            var appointment = new Appointment
            {
                Id           = Guid.NewGuid(),
                StartDate    = (DateTime)selectedAppointment.StartDate,
                EndDate      = (DateTime)selectedAppointment.EndDate,
                SpecialistId = specialist.Id
            };

            var appointmentService = new AppointmentsService();

            appointmentService.AddNewAppointment(appointment);
            MessageBox.Show("Dodano nową wizytę");
        }
예제 #7
0
        private async Task PrepareAppointmentsAsync(AppointmentsService service)
        {
            await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "11:00", "test comment");

            await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "12:00", "test comment");

            await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "13:00", "test comment");
        }
예제 #8
0
        public async Task CheckGettingAppointmentsHistoryUserAsync()
        {
            ApplicationDbContext db = GetDb();

            var repository = new EfDeletableEntityRepository <Appointment>(db);

            var usersService = new Mock <IUsersService>();
            var cardsService = new Mock <ICardsService>();

            var categoriesRepository = new EfDeletableEntityRepository <Category>(db);

            var categoryService = new CategoriesService(categoriesRepository);

            var proceduresRepository           = new EfDeletableEntityRepository <Procedure>(db);
            var procedureReviewsRepository     = new EfDeletableEntityRepository <Review>(db);
            var procedureProductsRepository    = new EfRepository <ProcedureProduct>(db);
            var procedureStylistsRepository    = new EfRepository <ProcedureStylist>(db);
            var skinProblemProcedureRepository = new EfRepository <SkinProblemProcedure>(db);

            var proceduresService = new ProceduresService(
                proceduresRepository,
                procedureReviewsRepository,
                procedureProductsRepository,
                procedureStylistsRepository,
                skinProblemProcedureRepository,
                repository,
                categoryService);

            var service = new AppointmentsService(
                repository,
                usersService.Object,
                cardsService.Object,
                proceduresService,
                categoryService);

            await db.Procedures.AddAsync(this.procedure);

            await db.Categories.AddAsync(this.category);

            await db.SaveChangesAsync();

            string appId = await this.GetAppointmentIdAsync(service);

            await service.DoneAsync(appId);

            var firstApp = await GetAppointmentAsync(repository, appId);

            firstApp.IsReview = true;

            repository.Update(firstApp);
            await repository.SaveChangesAsync();

            var resultAppointments = await
                                     service.GetHistoryUserAsync <TestAppointmentModel>(this.client.Id);

            Assert.Single(resultAppointments);
        }
예제 #9
0
 public ucKalendarUpis()
 {
     InitializeComponent();
     aS = new AppointmentsService();
     rs = new RadnikService();
     if (!(LicenseManager.UsageMode == LicenseUsageMode.Designtime))
     {
         radnici = rs.GetAllV();
     }
 }
 public PanelContent()
 {
     NewAppointment     = new Appointment();
     AppointmentService = new AppointmentsService();
     AppointmentService.Load();
     CurrentAppointments = new ObservableCollection <Appointment>();
     FillCurrentAppointments();
     AllPatientsAppointments = new ObservableCollection <CommandedAppointment>();
     FillAllAppointments();
 }
예제 #11
0
        public async Task CheckingAppointmentsForReviewAsync()
        {
            AppointmentsService service = await this.PrepareAppointmentReviewAsync();

            var hasToReview = await
                              service.CheckPastProceduresAsync(this.client.Id);

            var resultAppointments = await
                                     service.GetAppointmentsToReviewAsync <TestAppointmentModel>(this.client.Id);

            Assert.True(hasToReview);
            Assert.Single(resultAppointments);
        }
예제 #12
0
        private static AppointmentsService PreperaAppointmentServiceWithAllDependencies(ApplicationDbContext db)
        {
            var repository = new EfDeletableEntityRepository <Appointment>(db);

            var usersRepository             = new EfDeletableEntityRepository <ApplicationUser>(db);
            var skinProblemsRepository      = new EfDeletableEntityRepository <SkinProblem>(db);
            var clientSkinProblemRepository = new EfRepository <ClientSkinProblem>(db);
            var cardsRepository             = new EfDeletableEntityRepository <Card>(db);
            var cloudinaryService           = new Mock <ICloudinaryService>();

            var usersService = new UsersService(
                usersRepository,
                skinProblemsRepository,
                clientSkinProblemRepository,
                cardsRepository,
                cloudinaryService.Object);

            var cardTypesRepository = new EfDeletableEntityRepository <TypeCard>(db);

            var cardsService = new CardsService(
                cardTypesRepository,
                cardsRepository);

            var categoriesRepository = new EfDeletableEntityRepository <Category>(db);

            var categoryService = new CategoriesService(categoriesRepository);

            var proceduresRepository           = new EfDeletableEntityRepository <Procedure>(db);
            var procedureReviewsRepository     = new EfDeletableEntityRepository <Review>(db);
            var procedureProductsRepository    = new EfRepository <ProcedureProduct>(db);
            var procedureStylistsRepository    = new EfRepository <ProcedureStylist>(db);
            var skinProblemProcedureRepository = new EfRepository <SkinProblemProcedure>(db);

            var proceduresService = new ProceduresService(
                proceduresRepository,
                procedureReviewsRepository,
                procedureProductsRepository,
                procedureStylistsRepository,
                skinProblemProcedureRepository,
                repository,
                categoryService);

            var service = new AppointmentsService(
                repository,
                usersService,
                cardsService,
                proceduresService,
                categoryService);

            return(service);
        }
예제 #13
0
        private async Task PrepareAppointmentsAndStatusAsync(AppointmentsService service)
        {
            string firstAppId = await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "11:00", "test comment");

            string secondAppId = await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "12:00", "test comment");

            string thirdAppId = await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "13:00", "test comment");

            await service.DoneAsync(firstAppId);

            await service.DoneAsync(secondAppId);

            await service.CancelAsync(thirdAppId);
        }
예제 #14
0
        private AppointmentsService PrepareService()
        {
            ApplicationDbContext db = GetDb();

            var repository = new EfDeletableEntityRepository <Appointment>(db);
            var service    = new AppointmentsService(
                repository,
                this.usersService.Object,
                this.cardsService.Object,
                this.proceduresService.Object,
                this.categoriesService.Object);

            return(service);
        }
예제 #15
0
        public async void GetOwnerAppointmentsToListShouldReturnProperValues()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var appointmentsRepository  = new EfDeletableEntityRepository <Appointment>(new ApplicationDbContext(options.Options));
            var notificationsRepository = new EfDeletableEntityRepository <Notification>(new ApplicationDbContext(options.Options));

            var appointmentsService = new AppointmentsService(notificationsRepository, appointmentsRepository);

            var dogsitter = new Dogsitter();

            var owner = new Owner();

            var user = new ApplicationUser
            {
                Dogsitter = dogsitter,
                UserName  = "******",
                Email     = "*****@*****.**",
            };

            var user2 = new ApplicationUser
            {
                Owner    = owner,
                UserName = "******",
                Email    = "*****@*****.**",
            };

            var appointment = new Appointment
            {
                Status    = AppointmentStatus.Unprocessed,
                Date      = DateTime.UtcNow,
                StartTime = DateTime.UtcNow,
                EndTime   = DateTime.UtcNow.AddMinutes(5),
                Dogsitter = dogsitter,
                Owner     = owner,
            };

            dogsitter.Appointments.Add(appointment);
            dogsitter.UserId = user.Id;
            owner.Appointments.Add(appointment);
            owner.UserId = user2.Id;

            await appointmentsService.CreateNewAppointment(appointment);

            var appointments         = appointmentsService.GetOwnerAppointmentsToList(user2.Id);
            var comparedAppointments = String.Compare(appointment.Id, appointments.First().Id, StringComparison.Ordinal);

            Assert.Equal(0, comparedAppointments);
        }
        private void DeleteAppointment_OnClick(object sender, RoutedEventArgs e)
        {
            var selectedRow = this.AllAppointments.SelectedItem as AppointmentRowDto;

            if (selectedRow == null)
            {
                return;
            }

            var appointmentService = new AppointmentsService();

            appointmentService.DeleteAppointment(selectedRow.Id);

            this.GetCurrentAppointments();
        }
        public async Task GetAppointmentRequestsForTrainerShouldNotThrow()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;
            var db = new ApplicationDbContext(options);
            var appointmentsRepository = new EfDeletableEntityRepository <Appointment>(db);
            var usersRepository        = new EfDeletableEntityRepository <ApplicationUser>(db);
            var notificationsService   = new Mock <INotificationsService>();

            var service = new AppointmentsService(
                appointmentsRepository,
                usersRepository,
                notificationsService.Object);

            var client       = new ApplicationUser();
            var trainer      = new ApplicationUser();
            var role         = new ApplicationRole(GlobalConstants.TrainerRoleName);
            var identityRole = new IdentityUserRole <string>()
            {
                RoleId = role.Id,
                UserId = trainer.Id,
            };

            trainer.Roles.Add(identityRole);

            await usersRepository.AddAsync(trainer);

            await usersRepository.AddAsync(client);

            await usersRepository.SaveChangesAsync();

            var inputModel = new AddAppointmentInputModel()
            {
                StartTime  = DateTime.UtcNow,
                EndTime    = DateTime.UtcNow.AddDays(2),
                ClientId   = client.Id,
                TrainerId  = trainer.Id,
                IsApproved = true,
                Notes      = "Plamen",
                Type       = AppointmentType.Consultation,
            };

            var appointment = await service.AddAppoinmentAsync(inputModel);

            var result = await service.GetAppointmentRequestsForTrainer <TestAppointmentModel>(trainer.Id);

            Assert.Empty(result);
        }
        public AppointmentsService Before()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;
            var db = new ApplicationDbContext(options);
            var appointmentsRepository = new EfDeletableEntityRepository <Appointment>(db);
            var usersRepository        = new EfDeletableEntityRepository <ApplicationUser>(db);
            var notificationsService   = new Mock <INotificationsService>();

            var service = new AppointmentsService(
                appointmentsRepository,
                usersRepository,
                notificationsService.Object);

            return(service);
        }
        public async Task ApproveAppointmentShouldThrow(string clientId, string trainerId, int appointmentId)
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString()).Options;
            var db = new ApplicationDbContext(options);
            var appointmentsRepository = new EfDeletableEntityRepository <Appointment>(db);
            var usersRepository        = new EfDeletableEntityRepository <ApplicationUser>(db);
            var notificationsService   = new Mock <INotificationsService>();

            var service = new AppointmentsService(
                appointmentsRepository,
                usersRepository,
                notificationsService.Object);

            var client       = new ApplicationUser();
            var trainer      = new ApplicationUser();
            var role         = new ApplicationRole(GlobalConstants.TrainerRoleName);
            var identityRole = new IdentityUserRole <string>()
            {
                RoleId = role.Id,
                UserId = trainer.Id,
            };

            trainer.Roles.Add(identityRole);

            await usersRepository.AddAsync(trainer);

            await usersRepository.AddAsync(client);

            await usersRepository.SaveChangesAsync();

            var inputModel = new AddAppointmentInputModel()
            {
                StartTime  = DateTime.UtcNow,
                EndTime    = DateTime.UtcNow.AddDays(3),
                ClientId   = client.Id,
                TrainerId  = trainer.Id,
                IsApproved = true,
                Notes      = null,
                Type       = AppointmentType.Consultation,
            };

            var appointment = await service.AddAppoinmentAsync(inputModel);

            await Assert.ThrowsAnyAsync <InvalidOperationException>(async() =>
                                                                    await service.ApproveAppointment(appointmentId, trainerId, clientId));
        }
        private void GetCurrentAppointments()
        {
            var appointmentService     = new AppointmentsService();
            var specialistService      = new SpecialistsService();
            var allCurrentAppointments = appointmentService.GetAllSchedules();

            var retVal = (from appointment in allCurrentAppointments
                          let specialist = specialistService.GetSingleSpecialist(appointment.SpecialistId)
                                           select new AppointmentRowDto
            {
                Id = appointment.Id, StartDate = appointment.StartDate, EndDate = appointment.EndDate,
                FullName = specialist.FullName,
                Specialization = EnumTranslator.TranslateSpecializationEnum
                                     (Enum.GetName(typeof(Specialization), specialist.Specialization))
            }).ToList();

            this.AllAppointments.ItemsSource = retVal;
        }
예제 #21
0
        public async Task CheckCancelingAppointmentAsync()
        {
            ApplicationDbContext db = GetDb();

            var repository = new EfDeletableEntityRepository <Appointment>(db);
            var service    = new AppointmentsService(
                repository,
                this.usersService.Object,
                this.cardsService.Object,
                this.proceduresService.Object,
                this.categoriesService.Object);

            string appointmentId = await this.GetAppointmentIdAsync(service);

            await service.CancelAsync(appointmentId);

            var appointment = await GetAppointmentAsync(repository, appointmentId);

            Assert.Equal(Status.Cancelled, appointment.Status);
        }
예제 #22
0
        public async Task CreateAsyncWorksCorrectly()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext = new ApplicationDbContext(options);

            var addressesService = new Mock <IAddressesService>();

            var repository = new EfDeletableEntityRepository <Appointment>(dbContext);

            var service = new AppointmentsService(repository);

            var orderId   = Guid.NewGuid().ToString();
            var startDate = new DateTime(2020, 4, 27, 10, 0, 0);
            var endDate   = new DateTime(2020, 4, 27, 12, 0, 0);

            await service.CreateAsync(startDate, 2, orderId);

            var result = dbContext.Appointments.FirstOrDefault();

            Assert.Equal(result.EndDate, endDate);
        }
예제 #23
0
        public static Task Seed(PatientsService patientsService, AppointmentsService appointmentService,
                                ILoggerFactory loggerFactory)
        {
            var logger = loggerFactory.CreateLogger <DataContextSeed>();

            try
            {
                // seed patients
                for (int i = 1; i <= 5; i++)
                {
                    var patient = new Patient()
                    {
                        FirstName   = "Patient First" + i,
                        LastName    = "Patient Last" + i,
                        DateOfBirth = DateTime.Now.AddYears(i * -10)
                    };
                    patientsService.Create(patient);
                }

                for (int i = 1; i <= 5; i++)
                {
                    var appointment = new Appointment()
                    {
                        PatientId       = i,
                        AppointmentTime = DateTime.Now.AddDays(i * 5).AddHours(i * 2),
                        Notes           = "Give patient instructions on how to use prescribed medications."
                    };
                    appointmentService.Create(appointment);
                }
            }
            catch (Exception ex)
            {
                //var logger = loggerFactory.CreateLogger<DataContextSeed>();
                logger.LogError(ex, "An error occured during data seeding");
            }

            return(Task.FromResult(0));
        }
예제 #24
0
        private async Task <AppointmentsService> PrepareAppointmentReviewAsync()
        {
            ApplicationDbContext db = GetDb();

            var repository = new EfDeletableEntityRepository <Appointment>(db);

            var usersService = new Mock <IUsersService>();
            var cardsService = new Mock <ICardsService>();

            var categoriesRepository = new EfDeletableEntityRepository <Category>(db);

            var categoryService = new CategoriesService(categoriesRepository);

            var proceduresRepository           = new EfDeletableEntityRepository <Procedure>(db);
            var procedureReviewsRepository     = new EfDeletableEntityRepository <Review>(db);
            var procedureProductsRepository    = new EfRepository <ProcedureProduct>(db);
            var procedureStylistsRepository    = new EfRepository <ProcedureStylist>(db);
            var skinProblemProcedureRepository = new EfRepository <SkinProblemProcedure>(db);

            var proceduresService = new ProceduresService(
                proceduresRepository,
                procedureReviewsRepository,
                procedureProductsRepository,
                procedureStylistsRepository,
                skinProblemProcedureRepository,
                repository,
                categoryService);

            var service = new AppointmentsService(
                repository,
                usersService.Object,
                cardsService.Object,
                proceduresService,
                categoryService);

            await db.Procedures.AddAsync(this.procedure);

            await db.Categories.AddAsync(this.category);

            await db.SaveChangesAsync();

            var pastDate = DateTime.ParseExact("12/10/2020", "dd/MM/yyyy", CultureInfo.InvariantCulture);

            string firstAppId = await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, pastDate, "11:00", "test comment");

            string secondAppId = await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, pastDate, "12:00", "test comment");

            string thirdAppId = await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "13:00", "test comment");

            await service.DoneAsync(firstAppId);

            await service.DoneAsync(secondAppId);

            await service.DoneAsync(thirdAppId);

            var firstApp = await GetAppointmentAsync(repository, firstAppId);

            firstApp.IsReview = true;

            repository.Update(firstApp);
            await repository.SaveChangesAsync();

            return(service);
        }
예제 #25
0
 public AppointmentsController(AppointmentsService appointmentService)
 {
     _appointmentService = appointmentService;
 }
        private IEnumerable <Appointment> GetOccupiedDatesForSpecialist(DateTime dateTime)
        {
            var appointmentService = new AppointmentsService();

            return(appointmentService.GetSchedulesInDateRange(dateTime));
        }
예제 #27
0
 private async Task <string> GetAppointmentIdAsync(AppointmentsService service)
 {
     return(await service.CreateAsync(this.client.Id, this.stylist.Id, this.procedure.Id, DateTime.UtcNow, "11:00", "test comment"));
 }
예제 #28
0
        protected async void UpdateOpeningHoursClicked(object sender, EventArgs args)
        {
            var Mon_From = TimePicker11.Time.ToString();
            var Mon_Till = TimePicker12.Time.ToString();

            var Tue_From = TimePicker21.Time.ToString();
            var Tue_Till = TimePicker22.Time.ToString();

            var Wen_From = TimePicker31.Time.ToString();
            var Wen_Till = TimePicker32.Time.ToString();

            var Thur_From = TimePicker41.Time.ToString();
            var Thur_Till = TimePicker42.Time.ToString();

            var Fri_From = TimePicker51.Time.ToString();
            var Fri_Till = TimePicker52.Time.ToString();

            var Sat_From = TimePicker61.Time.ToString();
            var Sat_Till = TimePicker62.Time.ToString();

            var Sun_From = TimePicker71.Time.ToString();
            var Sun_Till = TimePicker72.Time.ToString();
            //
            Appointment ap = new Appointment();

            if (!Mon_From.Contains("00:00:00") && !Mon_Till.Contains("00:00:00"))
            {
                ap.open_from = Mon_From;
                ap.open_to   = Mon_Till;
            }
            else
            {
                if (Label1.IsVisible)
                {
                }
            }
            if (!Tue_From.Contains("00:00:00") && !Tue_Till.Contains("00:00:00"))
            {
                ap.open_from = Tue_From;
                ap.open_to   = Tue_Till;
            }
            else
            {
                if (Label2.IsVisible)
                {
                }
            }
            if (!Wen_From.Contains("00:00:00") && !Wen_Till.Contains("00:00:00"))
            {
                ap.open_from = Wen_From;
                ap.open_to   = Wen_Till;
            }
            else
            {
                if (Label3.IsVisible)
                {
                }
            }
            if (!Thur_From.Contains("00:00:00") && !Thur_Till.Contains("00:00:00"))
            {
                ap.open_from = Thur_From;
                ap.open_to   = Thur_Till;
            }
            else
            {
                if (Label4.IsVisible)
                {
                }
            }
            if (!Fri_From.Contains("00:00:00") && !Fri_Till.Contains("00:00:00"))
            {
                ap.open_from = Fri_From;
                ap.open_to   = Fri_Till;
            }
            else
            {
                if (Label5.IsVisible)
                {
                }
            }
            if (!Sat_From.Contains("00:00:00") && !Sat_Till.Contains("00:00:00"))
            {
                ap.open_from = Sat_From;
                ap.open_to   = Sat_Till;
            }
            else
            {
                if (Label6.IsVisible)
                {
                }
            }
            if (!Sun_From.Contains("00:00:00") && !Sun_Till.Contains("00:00:00"))
            {
                ap.open_from = Sun_From;
                ap.open_to   = Sun_Till;
            }
            else
            {
                if (Label7.IsVisible)
                {
                }
            }
            var credential = DependencyService.Get <ICredentialRetriever>().GetCredential();

            ap.user_id = credential.User.Id;

            AppointmentsService.SaveAppointment(ap);
            var page = new AppointmentsPage();
            await Navigation.PushAsync(page);
        }
예제 #29
0
        public AppointmentsPage()
        {
            InitializeComponent();
            NavigationPage.SetBackButtonTitle(this, "");
            _appointService = new AppointmentsService();
            _appointModel   = _appointService.GetCallbackHours();
            CrossConnectivity.Current.ConnectivityChanged += (sender, args) =>
            {
                UpdateBtn.IsEnableButton = args.IsConnected ? true : false;
            };

            TimePicker11.Time = ConvertStringToTimespan(_appointModel.Mon_From);
            TimePicker12.Time = ConvertStringToTimespan(_appointModel.Mon_Till);
            TimePicker21.Time = ConvertStringToTimespan(_appointModel.Tue_From);
            TimePicker22.Time = ConvertStringToTimespan(_appointModel.Tue_Till);
            TimePicker31.Time = ConvertStringToTimespan(_appointModel.Wen_From);
            TimePicker32.Time = ConvertStringToTimespan(_appointModel.Wen_Till);
            TimePicker41.Time = ConvertStringToTimespan(_appointModel.Thur_From);
            TimePicker42.Time = ConvertStringToTimespan(_appointModel.Thur_Till);
            TimePicker51.Time = ConvertStringToTimespan(_appointModel.Fri_From);
            TimePicker52.Time = ConvertStringToTimespan(_appointModel.Fri_Till);
            TimePicker61.Time = ConvertStringToTimespan(_appointModel.Sat_From);
            TimePicker62.Time = ConvertStringToTimespan(_appointModel.Sat_Till);
            TimePicker71.Time = ConvertStringToTimespan(_appointModel.Sun_From);
            TimePicker72.Time = ConvertStringToTimespan(_appointModel.Sun_Till);

            //set min and max time
            TimePicker11.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker11.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker12.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker12.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker21.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker21.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker22.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker22.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker31.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker31.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker32.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker32.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker41.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker41.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker42.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker42.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker51.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker51.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker52.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker52.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker61.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker61.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker62.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker62.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker71.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker71.MaximumTime = new TimeSpan(22, 0, 0);
            TimePicker72.MinimumTime = new TimeSpan(8, 0, 0);
            TimePicker72.MaximumTime = new TimeSpan(22, 0, 0);
            try
            {
                MonSwitch.IsToggled = _appointModel.LabelClose1 == "yes" ? true : false;
                TueSwitch.IsToggled = _appointModel.LabelClose2 == "yes" ? true : false;
                WedSwitch.IsToggled = _appointModel.LabelClose3 == "yes" ? true : false;
                ThuSwitch.IsToggled = _appointModel.LabelClose4 == "yes" ? true : false;
                FriSwitch.IsToggled = _appointModel.LabelClose5 == "yes" ? true : false;
                SatSwitch.IsToggled = _appointModel.LabelClose6 == "yes" ? true : false;
                SunSwitch.IsToggled = _appointModel.LabelClose7 == "yes" ? true : false;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("ex " + ex.InnerException + " " + ex.Message);
            }
        }
예제 #30
0
 public void SetUp()
 {
     BaseSetup();
     appointmentsService = new AppointmentsService(contextMock.Object);
 }