コード例 #1
0
        public ActionResult EditSchedule(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var schedule = db.Schedules.Single(c => c.Id == id);

            if (schedule.IsBooked == true)
            {
                ViewBag.Messege = "Schedule  has  been  Booked, can not be  adited";
                return(RedirectToAction("ListOfSchedules"));
            }
            schedule.PsychologistId = model.Schedule.PsychologistId;
            schedule.EndTime        = model.Schedule.EndTime;
            schedule.ScheduleDate   = model.Schedule.ScheduleDate;

            //  schedule.DepartmentId = model.Schedule.DepartmentId;
            schedule.StartTime = model.Schedule.StartTime;

            db.SaveChanges();

            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Updated Schedule Details", "Schedules");

            return(RedirectToAction("ListOfSchedules"));
        }
コード例 #2
0
        public ActionResult CreateAppointment(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var schedule = db.Schedules.Single(c => c.Id == id);

            schedule.PsychologistId  = model.Schedule.PsychologistId;
            schedule.EndTime         = model.Schedule.EndTime;
            schedule.ScheduleDate    = model.Schedule.ScheduleDate;
            schedule.Psychologist.Id = model.Schedule.Psychologist.Id;
            schedule.StartTime       = model.Schedule.StartTime;


            var appointment = new Appointment();

            // appointment.PatientId = mode;
            appointment.AppointmentDate = schedule.ScheduleDate;
            appointment.Problem         = model.Problem;
            appointment.Status          = false;
            db.Appointments.Add(appointment);
            db.SaveChanges();

            if (appointment.Status == true)
            {
                return(RedirectToAction("ListOfAppointments"));
            }
            else
            {
                return(RedirectToAction("PendingAppointments"));
            }
        }
コード例 #3
0
        public ActionResult AddSchedule(ScheduleCollection model)
        {
            var collection = new ScheduleCollection
            {
                Centres       = db.Centre.ToList(),
                Schedule      = model.Schedule,
                Psychologists = db.Psychologists.ToList()
            };

            if (model.Schedule.ScheduleDate <= DateTime.Now.Date)
            {
                ViewBag.Messege = "Please Enter the Date greater than today or equal!!";
                return(View(collection));
            }


            if (model.Schedule.EndTime < model.Schedule.StartTime.AddHours(1) || model.Schedule.EndTime > model.Schedule.StartTime.AddHours(1))
            {
                ViewBag.Messege = "Ops ,You Only allowed to to add schedule for 1 Hour Per slot.";
                return(View(collection));
            }
            ///     to fix  this isuue
            model.Schedule.CentreName       = db.Centre.FirstOrDefault(d => d.Id == model.Schedule.PsychologistId).Name;
            model.Schedule.PsychologistName = db.Psychologists.FirstOrDefault(db => db.Id == model.Schedule.PsychologistId).FullName;
            model.Schedule.IsBooked         = false;

            db.Schedules.Add(model.Schedule);
            db.SaveChanges();
            return(RedirectToAction("ListOfSchedules"));
        }
コード例 #4
0
 private void OnCancel()
 {
     if (AddMode)
     {
         ScheduleCollection.Remove(SelectedSchedule);
         SelectedSchedule = null;
         AddMode          = false;
     }
     else if (EditMode)
     {
         SelectedSchedule.CancelEdit();
         EditMode = false;
     }
     else if (RemoveMode)
     {
         foreach (var item in ScheduleCollection)
         {
             if (item.IsChecked)
             {
                 item.IsChecked = false;
             }
         }
         RemoveMode = false;
     }
     CanUseDatagrid = true;
     CanEditFields  = false;
 }
コード例 #5
0
        public ActionResult AddSchedule()
        {
            var collection = new ScheduleCollection
            {
                Schedule = new Schedule(),
                Doctors  = db.Doctors.ToList()
            };

            return(View(collection));
        }
コード例 #6
0
        public ActionResult EditSchedule(int id)
        {
            var collection = new ScheduleCollection
            {
                Schedule = db.Schedules.Single(c => c.Id == id),
                Doctors  = db.Doctors.ToList()
            };

            return(View(collection));
        }
コード例 #7
0
        public ActionResult EditSchedule(int id)
        {
            var collection = new ScheduleCollection
            {
                Centres       = db.Centre.ToList(),
                Schedule      = db.Schedules.Single(c => c.Id == id),
                Psychologists = db.Psychologists.ToList()
            };

            return(View(collection));
        }
コード例 #8
0
        public ActionResult AddSchedule()
        {
            var collection = new ScheduleCollection
            {
                Schedule      = new Schedule(),
                Centres       = db.Centre.ToList(),
                Psychologists = db.Psychologists.ToList()
            };

            return(View(collection));
        }
コード例 #9
0
        private string GetScheduleString(ApplicationPool iisPoolObject)
        {
            ScheduleCollection scheduleCollection = iisPoolObject.Recycling.PeriodicRestart.Schedule;

            if (scheduleCollection.Count == 0)
            {
                return("");                 //"\"\"";
            }
            string result = "";

            result += string.Join(", ", scheduleCollection.Select(s => s.Time));

            return("@(\"" + result.Trim() + "\")");
        }
コード例 #10
0
 private void OnAdd()
 {
     AddMode          = true;
     CanEditFields    = true;
     CanUseDatagrid   = false;
     SelectedSchedule = new ScheduleModel
     {
         Day            = DateTime.Now.DayOfWeek,
         Description    = "",
         AudioLocation  = "",
         PlayerLocation = Global.PlayerLocation,
         StartTime      = new TimeSpan(0, 0, 0),
         IsChecked      = false
     };
     ScheduleCollection.Add(SelectedSchedule);
 }
コード例 #11
0
        public ActionResult AddSchedule(ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                var collection = new ScheduleCollection
                {
                    Schedule = model.Schedule,
                    Doctors  = db.Doctors.ToList()
                };
                return(View(collection));
            }

            db.Schedules.Add(model.Schedule);
            db.SaveChanges();
            return(RedirectToAction("ListOfSchedules"));
        }
コード例 #12
0
        private void OnNewAddDateTimeSpanCommand()
        {
            currentPeriod       = new Period();
            currentPeriod.Begin = BeginDate.Date.Add(TimeSpan.Parse(startTime));             //TODO: Add TryCatch and Log
            currentPeriod.End   = EndDate.Date.Add(TimeSpan.Parse(endTime));

            currentPeriod.RepeatType = SelectedRepeatType;

            if (scheduler == null)
            {
                scheduler = new Scheduler();
            }

            scheduler.Schedule = ScheduleCollection;

            if (currentPeriod.End > currentPeriod.Begin)
            {
//				if(ScheduleCollection != null && ScheduleCollection.Count > 0)
//				{
//					for(int i = ScheduleCollection.Count; i > 0; i--)
//					{
//						if(
//							scheduler.Exist(currentPeriod)
//						)
//						{
//							if(new MessageBoxViewModel {
//							    Caption = "Already in list",
//							    Message = "This period overlaps",
//							    Buttons = MessageBoxButton.YesNo,
//							    Image = MessageBoxImage.Information
//							   }
//							   .Show(this.Dialogs) == MessageBoxResult.Yes)
//							{
//								ScheduleCollection.Add(currentPeriod);
//								return;
//							}
//							else
//								return;
//						}
//					}
//					ScheduleCollection.Add(currentPeriod);
//					return;
//				}
//				else if(ScheduleCollection != null)
                ScheduleCollection.Add(currentPeriod);
            }
        }
コード例 #13
0
        private ScheduleCollection CloneCollection([NotNull][ItemNotNull] ScheduleCollection collection)
        {
            ScheduleCollection newCollection = new ScheduleCollection();

            foreach (ScheduleElement element in collection)
            {
                newCollection.Add(new ScheduleElement
                {
                    Name       = element.Name,
                    Options    = element.Options,
                    Type       = element.Type,
                    Parameters = CloneCollection(element.Parameters)
                });
            }

            return(newCollection);
        }
コード例 #14
0
        public ActionResult EditSchedule(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var schedule = db.Schedules.Single(c => c.Id == id);

            schedule.PsychologistId = model.Schedule.PsychologistId;
            schedule.EndTime        = model.Schedule.EndTime;
            schedule.ScheduleDate   = model.Schedule.ScheduleDate;

            //  schedule.DepartmentId = model.Schedule.DepartmentId;
            schedule.StartTime = model.Schedule.StartTime;
            db.SaveChanges();
            return(RedirectToAction("ListOfSchedules"));
        }
コード例 #15
0
        public ActionResult EditSchedule(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var schedule = db.Schedules.Single(c => c.Id == id);

            schedule.DoctorId           = model.Schedule.DoctorId;
            schedule.AvailableEndDay    = model.Schedule.AvailableEndDay;
            schedule.AvailableEndTime   = model.Schedule.AvailableEndTime;
            schedule.AvailableStartDay  = model.Schedule.AvailableStartDay;
            schedule.AvailableStartTime = model.Schedule.AvailableStartTime;
            schedule.Status             = model.Schedule.Status;
            schedule.TimePerPatient     = model.Schedule.TimePerPatient;
            db.SaveChanges();
            return(RedirectToAction("ListOfSchedules"));
        }
コード例 #16
0
        public ActionResult CreateAppointment(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string user         = User.Identity.GetUserId();
            var    psychologist = db.Psychologists.Single(c => c.ApplicationUserId == user);

            var schedule = db.Schedules.Single(c => c.Id == id);

            schedule.PatientId      = model.Schedule.PatientId;
            schedule.EndTime        = model.Schedule.EndTime;
            schedule.ScheduleDate   = model.Schedule.ScheduleDate;
            schedule.StartTime      = model.Schedule.StartTime;
            schedule.PsychologistId = psychologist.Id;
            schedule.IsBooked       = true;
            db.SaveChanges();

            var appointment = new Appointment();

            appointment.PatientId       = schedule.PatientId;
            appointment.ScheduleId      = schedule.Id;
            appointment.AppointmentDate = schedule.ScheduleDate;
            appointment.StartTime       = schedule.StartTime;
            appointment.EndTime         = schedule.EndTime;
            appointment.Problem         = model.Problem;
            appointment.Status          = false;

            db.Appointments.Add(appointment);
            db.SaveChanges();

            if (appointment.Status == true)
            {
                return(RedirectToAction("ActiveAppointments"));
            }
            else
            {
                return(RedirectToAction("PendingAppointments"));
            }
        }
コード例 #17
0
        public ActionResult CreateAppointment(int id, ScheduleCollection model)
        {
            if (!ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            string user    = User.Identity.GetUserId();
            var    patient = db.Patients.Single(c => c.ApplicationUserId == user);

            if (patient.CompletedStatus == true || patient.BookedPsychologistId == 0)
            {
                var schedule = db.Schedules.Single(c => c.Id == id);
                schedule.PatientId = patient.Id;
                schedule.IsBooked  = true;
                db.SaveChanges();

                var appointment = new Appointment();
                appointment.PatientId       = patient.Id;
                appointment.ScheduleId      = schedule.Id;
                appointment.AppointmentDate = db.Schedules.FirstOrDefault(d => d.Id == schedule.Id).ScheduleDate;
                appointment.StartTime       = schedule.StartTime;
                appointment.EndTime         = schedule.EndTime;
                appointment.Problem         = model.Problem;
                appointment.Status          = false;
                appointment.CompletedStatus = false;

                db.Appointments.Add(appointment);
                db.SaveChanges();

                patient.BookedPsychologistId = db.Schedules.FirstOrDefault(d => d.Id == schedule.Id).PsychologistId;
                db.SaveChanges();
            }
            else
            {
                ModelState.AddModelError("error.error", "You  have still have an  ongoing appointment");
            }
            string audiuserName = User.Identity.GetUserName();

            AuditExtension.AddAudit(audiuserName, "Created Appointment", "Appointments");
            return(RedirectToAction("ListOfAppointments"));
        }
コード例 #18
0
 private bool CanSave()
 {
     if (RemoveMode)
     {
         if (ScheduleCollection.Any(x => x.IsChecked))
         {
             return(true);
         }
         return(false);
     }
     if (AddMode || EditMode)
     {
         if (SelectedSchedule.HasErrors)
         {
             return(false);
         }
         return(true);
     }
     return(false);
 }
コード例 #19
0
        public ActionResult CreateAppointment(int id)
        {
            try
            {
                var collection = new ScheduleCollection
                {
                    Centres       = db.Centre.ToList(),
                    Schedule      = db.Schedules.Single(c => c.Id == id),
                    Psychologists = db.Psychologists.ToList(),
                    Patients      = db.Patients.ToList()
                };
                return(View(collection));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }

            //if we get here something is wrong
            return(View());
        }
コード例 #20
0
        public ActionResult CreateAppointment(int id, ScheduleCollection model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                string user    = User.Identity.GetUserId();
                var    patient = db.Patients.Single(c => c.ApplicationUserId == user);

                var schedule = db.Schedules.Single(c => c.Id == id);
                schedule.PatientId = patient.Id;
                schedule.IsBooked  = true;
                db.SaveChanges();

                var appointment = new Appointment();
                appointment.PatientId       = patient.Id;
                appointment.ScheduleId      = schedule.Id;
                appointment.AppointmentDate = db.Schedules.FirstOrDefault(d => d.Id == schedule.Id).ScheduleDate;
                appointment.StartTime       = schedule.StartTime;
                appointment.EndTime         = schedule.EndTime;
                appointment.Problem         = model.Problem;
                appointment.Status          = false;

                db.Appointments.Add(appointment);
                db.SaveChanges();

                return(RedirectToAction("ListOfAppointments"));
            }
            catch (Exception error)
            {
                Console.WriteLine(error.Message);
            }

            //if we get here something is wrong
            return(View());
        }
コード例 #21
0
 public static void UpdateSchedules()
 {
     _schedules = null;
     Configuration = ConfigurationManager.RefreshSchedule();
 }
コード例 #22
0
        /// <summary>
        /// Returns all of the schedules defined for the current 
        /// application. The collection returned is read-only.
        /// </summary>
        public static ScheduleCollection GetSchedules()
        {
            if (_schedules == null)
            {
                lock (_schedulesSyncLock)
                {
                    if (_schedules == null)
                    {
                        ScheduleCollection schedules = new ScheduleCollection();

                        if (Configuration != null)
                        {
                            foreach (ScheduleSettings settings in Configuration.ScheduleSettings)
                            {
                                ScheduleBase schedule = ScheduleFactory.CreateSchedule(settings);
                                schedules.Add(schedule);
                            }
                        }

                        _schedules = schedules;
                    }
                }
            }

            return ScheduleCollection.ReadOnly(ScheduleCollection.FixedSize(_schedules));
        }
コード例 #23
0
        public static void AddSchedule(ScheduleBase schedule)
        {
            lock (_schedulesSyncLock)
            {
                try
                {
                    _schedules.Add(schedule);
                }
                catch (Exception)
                {
                    //_logger.Error(e.Message);
                }
            }

            if (_addedSchedules == null)
            {
                lock (_addedSchedulesSyncLock)
                {
                    if (_addedSchedules == null)
                    {
                        _addedSchedules = new ScheduleCollection();
                    }
                }
            }

            _addedSchedules.Add(schedule);
        }
コード例 #24
0
ファイル: ScheduleTests.cs プロジェクト: JulianTek/sPlannedIt
 public ScheduleTests()
 {
     _schedCol = new ScheduleCollection(_mockHandler.Object);
 }
コード例 #25
0
        private ScheduleCollection CloneCollection([NotNull][ItemNotNull] ScheduleCollection collection)
        {
            ScheduleCollection newCollection = new ScheduleCollection();

            foreach (ScheduleElement element in collection)
            {
                newCollection.Add(new ScheduleElement
                {
                    Name = element.Name,
                    Options = element.Options,
                    Type = element.Type,
                    Parameters = CloneCollection(element.Parameters)
                });
            }

            return newCollection;
        }
コード例 #26
0
        private async void OnSave()
        {
            if (AddMode)
            {
                var    schedule = Converter.ConvertFromScheduleModel(SelectedSchedule);
                int    id       = 0;
                bool   success  = true;
                string error    = "";
                OnInformationRequested("Loading...");
                await Task.Run(() =>
                {
                    try
                    {
                        using (Repository <Schedule> repo = new Repository <Schedule>())
                        {
                            var result = repo.InsertWithResult(schedule);
                            if (result.Status.Success)
                            {
                                id = result.Data.ID;
                            }
                            else
                            {
                                success = false;
                                error   = result.Status.ErrorMessage;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        error   = $"An error occured.Message: {ex.Message}";
                    }
                });

                if (success)
                {
                    SelectedSchedule.Id = id;
                    OnInformationRequested("Data added successfully, refreshing service in the background...");
                    await Task.Run(() =>
                    {
                        var result = Controller.RefreshService();
                        if (!result.Success)
                        {
                            success = false;
                            error   = result.ErrorMessage;
                        }
                    });

                    if (success)
                    {
                        OnInformationRequested("Service refreshed successfully");
                    }
                    else
                    {
                        OnErrorOccured(error);
                    }
                }
                else
                {
                    ScheduleCollection.Remove(SelectedSchedule);
                    SelectedSchedule = null;
                    OnErrorOccured(error);
                }
                AddMode = false;
            }
            else if (EditMode)
            {
                var schedule = Converter.ConvertFromScheduleModel(SelectedSchedule);

                bool   success = true;
                string error   = "";
                OnInformationRequested("Loading...");
                await Task.Run(() =>
                {
                    try
                    {
                        using (Repository <Schedule> repo = new Repository <Schedule>())
                        {
                            var result = repo.Update(schedule);
                            if (!result.Success)
                            {
                                success = false;
                                error   = result.ErrorMessage;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        error   = $"An error occured.Message: {ex.Message}";
                    }
                });

                if (success)
                {
                    SelectedSchedule.EndEdit();
                    OnInformationRequested("Data updated successfully, refreshing service in the background...");
                    await Task.Run(() =>
                    {
                        var result = Controller.RefreshService();
                        if (!result.Success)
                        {
                            success = false;
                            error   = result.ErrorMessage;
                        }
                    });

                    if (success)
                    {
                        OnInformationRequested("Service refreshed successfully");
                    }
                    else
                    {
                        OnErrorOccured(error);
                    }
                }
                else
                {
                    SelectedSchedule.CancelEdit();
                    OnErrorOccured(error);
                }
                EditMode = false;
            }
            else if (RemoveMode)
            {
                var temp = from item in ScheduleCollection
                           where item.IsChecked
                           select item;
                var    schedulesToRemove = temp.Select(x => Converter.ConvertFromScheduleModel(x));
                bool   success           = true;
                string error             = "";
                OnInformationRequested("Loading...");
                await Task.Run(() =>
                {
                    try
                    {
                        using (Repository <Schedule> repo = new Repository <Schedule>())
                        {
                            var result = repo.Delete(schedulesToRemove);
                            if (!result.Success)
                            {
                                success = false;
                                error   = result.ErrorMessage;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        success = false;
                        error   = $"An error occured.Message: {ex.Message}";
                    }
                });

                if (success)
                {
                    //to avoid Invalid Operation Exception
                    for (int i = 0; i < ScheduleCollection.Count; i++)
                    {
                        if (ScheduleCollection[i].IsChecked)
                        {
                            ScheduleCollection.RemoveAt(i);
                            i--;
                        }
                    }
                    OnInformationRequested("Data removed successfully, refreshing service in the background...");
                    await Task.Run(() =>
                    {
                        var result = Controller.RefreshService();
                        if (!result.Success)
                        {
                            success = false;
                            error   = result.ErrorMessage;
                        }
                    });

                    if (success)
                    {
                        OnInformationRequested("Service refreshed successfully");
                    }
                    else
                    {
                        OnErrorOccured(error);
                    }
                }
                else
                {
                    OnErrorOccured(error);
                }
                RemoveMode = false;
            }
            CanUseDatagrid = true;
            CanEditFields  = false;
        }