예제 #1
0
        // GET: Visits/Edit/5
        public ActionResult Edit(int?id, int customerId)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Visits visits = db.Visits.SingleOrDefault(x => x.Id == id);

            if (visits == null)
            {
                return(HttpNotFound());
            }

            VisitsViewModel vm = new VisitsViewModel
            {
                Id              = visits.Id,
                ContactPerson   = visits.ContactPerson,
                Comment         = visits.Comment,
                Date            = visits.Date,
                NextAppointment = visits.NextAppointment,
                CustomerId      = customerId
            };

            return(View(vm));
        }
        public ActionResult ApplyForAvisit()
        {
            int numberOfVisitsAtTheSameTime = 2;

            /*            select* from times
             *                    where time not in(
             *                    select visitTime from visitTimes
             *                    where num >= 2)
             *
             */

            /*        visit time view:
             *
             *             SELECT        dateOfVisit, VisitTime, COUNT(*) AS num
             *             FROM            dbo.visit
             *             GROUP BY dateOfVisit, VisitTime
             */
            var availableAppointments = db.GetAvailableAppointments(numberOfVisitsAtTheSameTime).ToList();

            VisitsViewModel visitView = new VisitsViewModel();

            visitView.availableAppointments = availableAppointments;


            return(View(visitView));
        }
        public ActionResult Index1()
        {
            VisitsViewModel visitsViewModel = new VisitsViewModel();

//            IEnumerable<VisitsViewModel> model = VisitsViewModel.GetPeople();

            return(View(visitsViewModel));
        }
예제 #4
0
        public ActionResult Create()
        {
            var             model     = new VisitsViewModel();
            var             testsList = _tests.GetAll();
            var             userId    = _user.GetUserId(HttpContext.User);
            ApplicationUser AppUser   = _user.FindByIdAsync(userId).Result;

            ViewBag.User     = AppUser;
            ViewBag.TestList = testsList;
            return(View(model));
        }
예제 #5
0
        public IActionResult Visits(VisitsViewModel model)
        {
            var result = _clinicService.BookVisit(GetLoggedUser(), model.DoctorId, model.Time);

            if (!result.Success)
            {
                return(ErrorPage());
            }

            return(RedirectToAction(nameof(HomeController.MyVisits), "Home"));
        }
예제 #6
0
        // GET: Visits/Create
        public ActionResult Create(int?id)
        {
            Customer customer = db.Customers.SingleOrDefault(x => x.Id == id);

            VisitsViewModel vm = new VisitsViewModel
            {
                CustomerName = customer.Name,
                CustomerId   = customer.Id
            };

            return(View(vm));
        }
예제 #7
0
        public ActionResult Index()
        {
            VisitsViewModel visitsViewModel = new VisitsViewModel();
            var             visits          = dataManager.Visits.GetVisits();

            visitsViewModel.Visits = visits;

            var dto = dataManager.Patients.GetDocsPatientsDTO();

            visitsViewModel.DocsPatientsDTO = dto;

            return(View(visitsViewModel));
        }
예제 #8
0
 public ActionResult Create(VisitsViewModel model)
 {
     if (ModelState.IsValid)
     {
         Visit one = new Visit();
         one.Status   = "Oczekująca";
         one.TestsId  = CartHelper.GetCart();
         one.dateTime = model.Date;
         one.User     = _user.FindByIdAsync(_user.GetUserId(HttpContext.User)).Result;
         _visits.Add(one);
         CartHelper.ResetCart();
     }
     ViewBag.Save = 1;
     return(RedirectToAction("Create"));
 }
예제 #9
0
        public IActionResult Create(VisitsViewModel model)
        {
            if (ModelState.IsValid)
            {
                var visit = new Visit {
                    FirstName = model.Visit.FirstName,
                    LastName  = model.Visit.LastName,
                    BarberId  = model.Visit.BarberId,
                };
                visit.Barber = _context.Barbers.SingleOrDefault(x => x.BarberId == model.Visit.BarberId);

                var currentVisits     = _context.Visits;
                var barbersVisitCount = currentVisits.Where(x => x.BarberId != null).GroupBy(g => g.BarberId)
                                        .ToDictionary(gx => gx.Key, gx => gx.ToList());

                int activeVisitors = currentVisits.Count() -
                                     currentVisits.Where(x => x.isCheckedOff).Count();
                var shop = _context.Shops.First();

                if (visit.Barber != null)
                {
                    var bvc = 0;
                    if (!currentVisits.Any(x => x.BarberId == model.Visit.BarberId))
                    {
                        bvc = 0;
                    }
                    else
                    {
                        bvc = barbersVisitCount[visit.BarberId].Count;
                    }
                    visit.WaitTime = _waitcalc
                                     .CalculateWaitPerVisit(activeVisitors,
                                                            shop.CutTimeAverage,
                                                            visit.Barber.AvgCutTime,
                                                            bvc);
                }
                else
                {
                    visit.WaitTime = (shop.CutTimeAverage * activeVisitors);
                }

                visit.SignInTime = DateTime.Now;
                _context.Visits.Add(visit);
                _context.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View("Index"));
        }
예제 #10
0
        public IActionResult Visits()
        {
            //var visits = _appDbContext.PageVisits.OrderByDescending(x => x.PageVisitId).Take(100);

            //var visitsByPath = visits.GroupBy(x => x.Path).Select(group => new KeyValuePair<string, int>(group.Key, group.Count())).OrderByDescending(x => x.Value).Take(100);

            //var visitsByIp = visits.GroupBy(x => x.Ip).Select(group => new KeyValuePair<string, int>(group.Key, group.Count())).OrderByDescending(x => x.Value).Take(100);

            VisitsViewModel model = new VisitsViewModel
            {
                Visits = new List <PageVisit>(),
                ByPath = new List <KeyValuePair <string, int> >(),
                ByIp   = new List <KeyValuePair <string, int> >()
            };

            return(View(model));
        }
예제 #11
0
        public ActionResult List(short page = 1, short pageSize = 6, string orderBy = "CreatedOn")
        {
            var pagedVisits = this.pageService
                              .GetPage(page, pageSize, orderBy)
                              .Select(v => new VisitCardViewModel(v));

            var pages = this.pageService.Count / pageSize;

            pages = this.pageService.Count % pageSize == 0 ? pages : ++pages;

            var vm = new VisitsViewModel()
            {
                Visits    = pagedVisits,
                PageCount = pages
            };

            return(PartialView("_VisitsListPartial", vm));
        }
예제 #12
0
        public ActionResult Edit(VisitsViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Visits visit = new Visits
                {
                    Id              = vm.Id,
                    ContactPerson   = vm.ContactPerson,
                    Comment         = vm.Comment,
                    Date            = vm.Date,
                    NextAppointment = vm.NextAppointment
                };

                db.Entry(visit).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Details", "Customers", new { id = vm.CustomerId }));
            }
            return(View(vm));
        }
        public ActionResult ApplyForAvisit(VisitsViewModel visitViewModel)
        {
            int prisonerid = Convert.ToInt32(Session["prisonerid"]);

            var prisoner = (from item in db.Prisoners
                            where item.prisonerID == prisonerid
                            select item).FirstOrDefault();

            visitViewModel.visit.VisitTime = visitViewModel.selectedAppointment;
            visit visit = new visit();

            visit            = visitViewModel.visit;
            visit.Prisoner   = prisoner;
            visit.prisonerid = prisonerid;

            db.Entry(visit).State = EntityState.Added;
            db.SaveChanges();

            return(Redirect("~/public/index"));
        }
예제 #14
0
        public ActionResult Create(VisitsViewModel vm)
        {
            if (ModelState.IsValid)
            {
                Visits visit = new Visits
                {
                    ContactPerson   = vm.ContactPerson,
                    Comment         = vm.Comment,
                    Date            = vm.Date,
                    NextAppointment = vm.NextAppointment
                };

                Customer customer = db.Customers.SingleOrDefault(x => x.Id == vm.CustomerId);
                customer.Visits.Add(visit);
                db.Customers.AddOrUpdate(customer);
                db.Visits.Add(visit);
                db.SaveChanges();
                return(RedirectToAction("Details", "Customers", new { id = vm.CustomerId }));
            }

            return(View(vm));
        }
예제 #15
0
        public IActionResult Index(int apartamentPage = 1)
        {
            List <Visit> visits = _repo.Visits.OrderByDescending(v => v.OpenDate).ToList();

            foreach (var visit in visits)
            {
                visit.Visitor    = _repo.Visitors.FirstOrDefault(v => v.Id == visit.VisitorId);
                visit.Apartments = _repo.Apartments.FirstOrDefault(a => a.Id == visit.ApartamentId);
            }

            var viewModel = new VisitsViewModel
            {
                Visits     = visits,
                PagingInfo = new PagingInfo
                {
                    CurrentPage  = apartamentPage,
                    ItemsPerPage = pageSize,
                    Totalitems   = _repo.Visits.Count()
                }
            };

            return(View(viewModel));
        }
예제 #16
0
        public ActionResult Index()
        {
            VisitsViewModel visitsViewModel = new VisitsViewModel();
            var             visits          = dataManager.Visits.GetVisits();

            visitsViewModel.Visits = visits;

            var doctors  = dataManager.Doctors.GetDoctors();
            var patients = dataManager.Patients.GetPatients();

            var doctornames = from x in visits
                              join t in doctors on x.DoctorId equals t.DoctorId
                              select t.Name;

            visitsViewModel.DoctorName = doctornames.ToList();

            var doctorsurnames = from x in visits
                                 join t in doctors on x.DoctorId equals t.DoctorId
                                 select t.Surname;

            visitsViewModel.DoctorSurname = doctorsurnames.ToList();

            var patientnames = from x in visits
                               join t in patients on x.PatientId equals t.PatientId
                               select t.Name;

            visitsViewModel.PatientName = patientnames.ToList();

            var patientsurnames = from x in visits
                                  join t in patients on x.PatientId equals t.PatientId
                                  select t.Surname;

            visitsViewModel.PatientSurname = patientsurnames.ToList();

            return(View(visitsViewModel));
        }
예제 #17
0
        public ReportViewModel GetReportData(DateTime?fromVisitDate, DateTime?toVisitDate, int?visitSettingId, int?participantId)
        {
            IList <Visits> visits = new List <Visits>();


            visits = _smokingStudyDbContext.Visits.Where(v =>
                                                         (!fromVisitDate.HasValue || v.VisitDate.Date >= fromVisitDate) &&
                                                         (!toVisitDate.HasValue || v.VisitDate.Date <= toVisitDate) &&
                                                         (!visitSettingId.HasValue || v.VisitSetting.Id == visitSettingId) &&
                                                         (!participantId.HasValue || v.Participant.Id == participantId))
                     .Include(p => p.Participant)
                     .Include(s => s.VisitSetting)
                     .ToList();


            var reportVM = new ReportViewModel();

            //reportVM.VisitTypes = new SelectList(GetVisitSettingSL(), "VisitSettingId", "VisitType");
            reportVM.Participants = new SelectList(GetParticipantsSL(), "ParticipantId", "StudyId");

            foreach (var visit in visits)
            {
                var vm = new VisitsViewModel()
                {
                    StudyId        = visit.Participant.StudyId,
                    VisitDate      = visit.VisitDate,
                    VisitType      = visit.VisitSetting.VisitType,
                    VisitId        = visit.Id,
                    VisitSettingId = visit.VisitSettingId
                };

                reportVM.Visits.Add(vm);
            }

            return(reportVM);
        }
예제 #18
0
        public static void Show(VisitsViewModel model)
        {
            VisitsControl control = new VisitsControl()
            {
                DataContext = model
            };

            if (control != null)
            {
                Window wnd = new Window
                {
                    HorizontalAlignment   = HorizontalAlignment.Right,
                    VerticalAlignment     = VerticalAlignment.Top,
                    SizeToContent         = SizeToContent.WidthAndHeight,
                    WindowStartupLocation = WindowStartupLocation.CenterScreen,
                    // ResizeMode = ResizeMode.NoResize
                };



                Grid newGrid = new Grid()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };

                RowDefinition R1 = new RowDefinition();
                R1.Height = new GridLength(12, GridUnitType.Star);
                newGrid.RowDefinitions.Add(R1);
                RowDefinition R2 = new RowDefinition();
                R2.Height = new GridLength(50);
                newGrid.RowDefinitions.Add(R2);
                RowDefinition R3 = new RowDefinition();
                R3.Height = new GridLength(50);

                newGrid.RowDefinitions.Add(R3);
                wnd.Content = newGrid;

                Grid.SetRow(control, 0);
                newGrid.Children.Add(control);


                // Панель для двух кнопок
                Grid buttonGrid = new Grid()
                {
                    HorizontalAlignment = HorizontalAlignment.Stretch,
                    VerticalAlignment   = VerticalAlignment.Stretch
                };

                ColumnDefinition C1 = new ColumnDefinition();
                C1.Width = new GridLength(1, GridUnitType.Star);
                buttonGrid.ColumnDefinitions.Add(C1);
                ColumnDefinition C2 = new ColumnDefinition();
                C2.Width = new GridLength(2, GridUnitType.Star);
                buttonGrid.ColumnDefinitions.Add(C2);
                ColumnDefinition C3 = new ColumnDefinition();
                C3.Width = new GridLength(1, GridUnitType.Star);
                buttonGrid.ColumnDefinitions.Add(C3);

                Grid.SetRow(buttonGrid, 1);
                newGrid.Children.Add(buttonGrid);

                // кнопка отказа
                Button closeButton = new Button                {
                    Content             = "Отказаться от изменений и закрыть",
                    HorizontalAlignment = HorizontalAlignment.Right,
                    Width             = 200,
                    Height            = 35,
                    VerticalAlignment = VerticalAlignment.Top
                };
                closeButton.Click += (s, e) => {
                    model.UnDoChanges();
                    wnd.Close();
                };
                Grid.SetColumn(closeButton, 0);
                buttonGrid.Children.Add(closeButton);
                // кнопка сохранения
                Button applyButton = new Button
                {
                    Content             = "Сохранить и закрыть",
                    HorizontalAlignment = HorizontalAlignment.Left,
                    Width             = 200,
                    Height            = 35,
                    VerticalAlignment = VerticalAlignment.Top
                };
                applyButton.Click += (s, e) => {
                    acceptChanges = 1;
                    model.Save();
                    wnd.Close();
                };
                Grid.SetColumn(applyButton, 2);
                buttonGrid.Children.Add(applyButton);


                wnd.Closed += (s, e) => wnd.Close();
                wnd.ShowDialog();
            }
        }
 public VisitListPage()
 {
     InitializeComponent();
     BindingContext = viewModel = new VisitsViewModel();
     NavigationPage.SetHasNavigationBar(this, false);
 }
 public VisitListPage(Guest selectedGuest)
 {
     InitializeComponent();
     this.selectedGuest = selectedGuest;
     BindingContext     = viewModel = new VisitsViewModel(selectedGuest);
 }
예제 #21
0
        public List <VisitsViewModel> LoadScheduledVisits()
        {
            var scheduledVisits = _smokingStudyDbContext.Schedules
                                  .Where(s => s.WindowStart.Value.Date >= DateTime.Now.Date);

            var scheduled_Visits = _smokingStudyDbContext.Visits
                                   .Where(v => v.NextAppointment >= DateTime.Now.Date && v.Deleted != 1);

            var scheduledVisitsVM = new List <VisitsViewModel>();

            foreach (var scheduledVisit in scheduledVisits)
            {
                var nextVisitStage = scheduledVisit.VisitStage + 1;
                var participantId  = _smokingStudyDbContext.Participants.Where(p => p.StudyId == scheduledVisit.studyId).FirstOrDefault().Id;

                var scheduledVisitVM = new VisitsViewModel();

                scheduledVisitVM.StudyId    = scheduledVisit.studyId;
                scheduledVisitVM.Medication = _smokingStudyDbContext.VisitSettings.Where(v => v.VisitStage == scheduledVisit.VisitStage).FirstOrDefault().Medication;
                scheduledVisitVM.VisitType  = _smokingStudyDbContext.VisitSettings.Where(v => v.VisitStage == scheduledVisit.VisitStage).FirstOrDefault().VisitType;
                scheduledVisitVM.VisitDate  = scheduledVisit.WindowStart.Value.Date;
                scheduledVisitVM.VisitId    = scheduledVisit.VisitStage;

                scheduledVisitsVM.Add(scheduledVisitVM);
            }

            foreach (var visit in scheduled_Visits)
            {
                var sturdyId           = GetParticipantStudyId(visit.ParticipantId);
                var visitSettingId     = visit.VisitSettingId;
                int nextVisitSettingId = 0;

                if (visitSettingId <= 9)
                {
                    nextVisitSettingId = visitSettingId + 1;

                    if (nextVisitSettingId > 9)
                    {
                        continue;
                    }

                    var exists = scheduledVisitsVM.Where(v => v.StudyId == sturdyId && v.VisitId == nextVisitSettingId).FirstOrDefault();

                    if (exists != null)
                    {
                        continue;
                    }

                    var scheduledVisitVM = new VisitsViewModel();

                    scheduledVisitVM.StudyId    = sturdyId;
                    scheduledVisitVM.Medication = _smokingStudyDbContext.VisitSettings.Where(v => v.VisitStage == nextVisitSettingId).FirstOrDefault().Medication;
                    scheduledVisitVM.VisitType  = _smokingStudyDbContext.VisitSettings.Where(v => v.VisitStage == nextVisitSettingId).FirstOrDefault().VisitType;
                    scheduledVisitVM.VisitDate  = visit.NextAppointment.Value;
                    scheduledVisitVM.VisitId    = nextVisitSettingId;

                    scheduledVisitsVM.Add(scheduledVisitVM);
                }
                else
                {
                    nextVisitSettingId = visitSettingId + 1;

                    if (nextVisitSettingId > 17)
                    {
                        continue;
                    }

                    var exists = scheduledVisitsVM.Where(v => v.StudyId == sturdyId && v.VisitId == nextVisitSettingId).FirstOrDefault();

                    if (exists != null)
                    {
                        continue;
                    }

                    var scheduledVisitVM = new VisitsViewModel();

                    scheduledVisitVM.StudyId    = sturdyId;
                    scheduledVisitVM.Medication = _smokingStudyDbContext.VisitSettings.Where(v => v.VisitStage == nextVisitSettingId).FirstOrDefault().Medication;
                    scheduledVisitVM.VisitType  = _smokingStudyDbContext.VisitSettings.Where(v => v.VisitStage == nextVisitSettingId).FirstOrDefault().VisitType;
                    scheduledVisitVM.VisitDate  = visit.NextAppointment.Value;
                    scheduledVisitVM.VisitId    = nextVisitSettingId;

                    scheduledVisitsVM.Add(scheduledVisitVM);
                }
            }

            return(scheduledVisitsVM);
        }