Пример #1
0
        private ObservableCollection <DataGridAppoimentsViewModel> FillDataGrid()
        {
            CustomPrincipal customPrincipal = Thread.CurrentPrincipal as CustomPrincipal;
            string          currentEmail    = customPrincipal.Identity.Email;
            var             context         = new MedicalDBEntities();
            var             query           = context.Users
                                              .Where(s => s.email == currentEmail)
                                              .FirstOrDefault <User>();
            User currentUser = query;


            var appoimentsQuery = from st in context.Appoiments
                                  where st.idUser == currentUser.idUser
                                  select st;
            var app = appoimentsQuery.FirstOrDefault <Appoiment>();
            ObservableCollection <Appoiment> appoiments = new ObservableCollection <Appoiment>();

            foreach (var ap in appoimentsQuery)
            {
                appoiments.Add(ap);
            }
            DataGridAppoimentsViewModel data = new DataGridAppoimentsViewModel();
            ObservableCollection <DataGridAppoimentsViewModel> source = new ObservableCollection <DataGridAppoimentsViewModel>();

            source = data.FillAppoimentsGrid(appoiments);
            return(source);
        }
Пример #2
0
        public ObservableCollection <DataGridAppoimentsViewModel> FillAppoimentsGrid(ObservableCollection <Appoiment> Appoiments)
        {
            ObservableCollection <DataGridAppoimentsViewModel> data = new ObservableCollection <DataGridAppoimentsViewModel>();

            foreach (Appoiment ap in Appoiments)
            {
                DataGridAppoimentsViewModel apData = new DataGridAppoimentsViewModel();
                apData.Date           = ap.date.ToString("dd/MM/yyyy");
                apData.Doctor         = GetDoctor(ap.idDoctor);
                apData.Specialization = GetSpecialization(ap.idService);
                apData.Service        = GetService(ap.idService);
                apData.StartHour      = ap.startTime;
                apData.FinishHour     = ap.startTime + 1;
                apData.AppoimentId    = ap.idAppoiment;
                data.Add(apData);
            }
            return(data);
        }