Example #1
0
 /// <summary>
 /// Creates the AddRequestForm Window and Initializes DB Param.
 /// </summary>
 public ConfirmDeleteTimeSlotWindow(TimeSlots sender, string timeslot_id)
 {
     tid       = timeslot_id;
     timeslots = sender;
     pmsutil   = new PMSUtil();
     InitializeComponent();
 }
Example #2
0
        //this method is called when the user posts the appointment online. It takes in the data and creates a new instance of an appointment that is then added and saved to the DB
        public IActionResult OnPost(string Time, string Name, int Size, string Email, string PhoneNum) //saves to DB
        {
            var appt = new Appointment
            {
                ApptTime = DateTime.Parse(Time),
                Name     = Name,
                Size     = Size,
                Email    = Email,
                PhoneNum = PhoneNum
            };

            Apptcontext.appointments.Add(appt);
            Apptcontext.SaveChanges();

            //this then gets the time that the user successfully signed up for and changes it to not available so that 2 users can't sign up for the same time.
            TimeSlots time = Timecontext.TimeSlots
                             .FirstOrDefault(x => x.AvailableTime == appt.ApptTime);

            time.IsAvailable = false;
            Timecontext.SaveChanges();
            //foreach (var i in time)
            //{
            //    i.IsAvailable = false;
            //}

            //takes the user back to the home when they submit
            return(RedirectToPage("Index"));
        }
        private void AddTimeSlot()
        {
            PracticeRoutineTimeSlot timeSlot = new PracticeRoutineTimeSlot("New Time Slot", 300, new List <TimeSlotExercise>());

            practiceRoutine.Add(timeSlot);
            TimeSlots.Add(new TimeSlotViewModel(timeSlot));
        }
Example #4
0
        public Dictionary <Course, Dictionary <TimeSlot, Dictionary <Room, double> > > ReadSolution(string path)
        {
            var result = new Dictionary <Course, Dictionary <TimeSlot, Dictionary <Room, double> > >();

            foreach (var course in Courses)
            {
                result.Add(course, new Dictionary <TimeSlot, Dictionary <Room, double> >());
                foreach (var timeslot in TimeSlots)
                {
                    result[course].Add(timeslot, new Dictionary <Room, double>());
                    foreach (var room in Rooms)
                    {
                        result[course][timeslot].Add(room, 0.0);
                    }
                }
            }

            foreach (var line in File.ReadLines(path))
            {
                var elements = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                if (elements.Length != 4)
                {
                    continue;
                }

                var course   = Courses.First(c => c.ID.CompareTo(elements[0]) == 0);
                var room     = Rooms.First(r => r.ID.CompareTo(elements[1]) == 0);
                var timeslot = TimeSlots.First(t => t.Day == int.Parse(elements[2]) && t.Period == int.Parse(elements[3]));

                result[course][timeslot][room] += 1;
            }
            return(result);
        }
Example #5
0
        public BookRessourceViewModel()
        {
            proxy        = AutofacHelper.Container.Resolve <ApiClientProxy>();
            drawBookning = new DrawResourcer();
            Date         = DateTime.Now;
            StartTime    = DateTime.Now.TimeOfDay;
            SlutTime     = DateTime.Now.TimeOfDay;

            _hubConnectionRerservation = new HubConnectionBuilder()
                                         .WithUrl($"{Resources.SignalRBaseAddress}ReservationHub").Build();
            _hubConnectionRerservation.StartAsync();
            _hubConnectionResource =
                new HubConnectionBuilder().WithUrl($"{Resources.SignalRBaseAddress}ResourceHub").Build();
            _hubConnectionResource.StartAsync();

            //SignalR Client methods for Reservation
            _hubConnectionRerservation.On <Reservation>("CreateReservation", reservation =>
            {
                Reservations.Add(reservation);
                reftesh(reservation.Timeslot.FromDate.DayOfWeek);
            });
            _hubConnectionRerservation.On <Reservation>("UpdateReservation", reservation =>
            {
                Reservations[Reservations.FindIndex(r => r.Id == reservation.Id)] = reservation;
                reftesh();
            });
            _hubConnectionRerservation.On <Reservation>("DeleteReservation", reservation =>
            {
                Reservations.RemoveAt(Reservations.FindIndex(re => reservation.Id == re.Id));
                reftesh(reservation.Timeslot.FromDate.DayOfWeek);
            });

            //SignalR Client methods for Resource
            _hubConnectionResource.On <Resource>("UpdateResource", resource =>
            {
                if (resource.Id == Id)
                {
                    if (resource.TimeSlots == null)
                    {
                        TimeSlots = new List <AvailableTime>();
                        reftesh();
                    }

                    foreach (var timeslot in resource.TimeSlots)
                    {
                        if (TimeSlots.Find(r => r.Id == timeslot.Id) != null)
                        {
                            TimeSlots[TimeSlots.FindIndex(r => r.Id == timeslot.Id)] = timeslot;
                            reftesh();
                        }
                        else
                        {
                            TimeSlots.Add(timeslot);
                            reftesh();
                        }
                    }
                }
            });
        }
        public ActionResult DeleteConfirmed(int id)
        {
            TimeSlots timeSlots = db.TimeSlots.Find(id);

            db.TimeSlots.Remove(timeSlots);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public static string GetDisplayName(this TimeSlots enumValue)
 {
     return(enumValue.GetType()
            .GetMember(enumValue.ToString())
            .First()
            .GetCustomAttribute <DisplayAttribute>()
            .GetName());
 }
        public ActionResult Edit(int id, TimeSlots timeSlots)
        {
            HttpClient httpClient = new HttpClient();

            httpClient.BaseAddress = new Uri("https://localhost:44362/");
            HttpResponseMessage tokenResponse = httpClient.PutAsJsonAsync <TimeSlots>("http://localhost:8081/Dari/servlet/Asset/RDVTS/" + id + "/Modify", timeSlots).Result;

            return(RedirectToAction("Index2/" + id));
        }
        public IActionResult SignUp(int TimeSlotId)
        {
            //creating a variable to pass through the ViewBag, this will allow us to pass the Time Slot information directly into the form.
            TimeSlots appointment = context.TimeSlots.Where(t => t.TimeSlotId == TimeSlotId).FirstOrDefault();

            ViewBag.TimeSlot = appointment;

            //directs the page to the Form view.
            return(View("Form"));
        }
 public ActionResult Edit([Bind(Include = "TimeSlotId,SlotTime")] TimeSlots timeSlots)
 {
     if (ModelState.IsValid)
     {
         db.Entry(timeSlots).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(timeSlots));
 }
        public static bool CheckITimeSlot(TimeSlots timeSlots)
        {
            bool result   = false;
            var  dbRecord = _db.TimeSlots.Where(x => x.SlotTime == timeSlots.SlotTime).FirstOrDefault();

            if (dbRecord != null)
            {
                result = true;
            }
            return(result);
        }
        public ActionResult Create([Bind(Include = "TimeID,SlotTime")] TimeSlots timeSlots)
        {
            if (ModelState.IsValid)
            {
                db.TimeSlots.Add(timeSlots);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(timeSlots));
        }
Example #13
0
        public async Task <JsonResult> GetTimeSlots(int guests, string date)
        {
            DateTime  dt        = DateTime.ParseExact(date, "MM/dd/yyyy", CultureInfo.InvariantCulture);
            TimeSlots timeslots = new TimeSlots(dt);

            foreach (TimeSlot slot in timeslots.slots)
            {
                slot.isAvailable = ReservationLogic.isAvailable(_context, guests, ReservationLogic.getTableCount(_context), slot);
            }
            return(Json(timeslots.slots));
        }
Example #14
0
        public static TimeSlots GetTime(string datetime)
        {
            var time = Convert.ToDateTime(datetime);

            var timeSlots = new TimeSlots();

            timeSlots.Hour   = time.Hour;
            timeSlots.Minute = time.Minute;
            timeSlots.Second = time.Second;

            return(timeSlots);
        }
Example #15
0
 public TableReservation(Table table, Account account, DateTime date, TimeSlots timeSlot)
 {
     Table    = table;
     Account  = account;
     Date     = date;
     TimeSlot = timeSlot;
     if (!Reservations.ContainsKey(date))
     {
         Reservations[date] = new List <TableReservation>();
     }
     Reservations[date].Add(this);
 }
        private void GenerateTimeSlots()
        {
            // Generate a time slot for each time interval based on duration length
            this.TimeSlots = new List <TimeSlot>();
            int totalHours = StartingHour;

            for (int i = 0; i < NumberOfSlots; i++)
            {
                var slot = new TimeSlot(Date.AddHours(totalHours));
                totalHours += int.Parse(SlotDurationInHours.ToString());
                TimeSlots.Add(slot);
            }
        }
        private void GetWebSchedTimeSlotsWorker(ODThread o)
        {
            WebSchedTimeSlotArgs w             = (WebSchedTimeSlotArgs)o.Parameters[0];
            List <TimeSlot>      listTimeSlots = new List <TimeSlot>();

            try {
                //Get the next 30 days of open time schedules with the current settings
                listTimeSlots = TimeSlots.GetAvailableWebSchedTimeSlots(w.RecallTypeCur, w.ListProviders, w.ClinicCur, w.DateStart, w.DateEnd);
            }
            catch (Exception) {
                //The user might not have Web Sched ops set up correctly.  Don't warn them here because it is just annoying.  They'll figure it out.
            }
            o.Tag = listTimeSlots;
        }
Example #18
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));
        }
        // GET: TimeSlots/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TimeSlots timeSlots = db.TimeSlots.Find(id);

            if (timeSlots == null)
            {
                return(HttpNotFound());
            }
            return(View(timeSlots));
        }
Example #20
0
        public TimeSlots ParseTimeSlots()
        {
            var ts = new TimeSlots();

            ts.TimeSlotLockDays = GetNullInt();
            if (curr.indent == 0)
            {
                return(ts);
            }
            var startindent = curr.indent;

            while (curr.indent == startindent)
            {
                var slot = new TimeSlots.TimeSlot();
                if (curr.kw != Parser.RegKeywords.None)
                {
                    throw GetException("unexpected line in TimeSlots");
                }
                slot.Description = GetLine();
                if (curr.indent <= startindent)
                {
                    ts.list.Add(slot);
                    continue;
                }
                var ind = curr.indent;
                while (curr.indent == ind)
                {
                    switch (curr.kw)
                    {
                    case Parser.RegKeywords.Time:
                        slot.Time = GetTime();
                        break;

                    case Parser.RegKeywords.DayOfWeek:
                        slot.DayOfWeek = GetInt();
                        break;

                    case Parser.RegKeywords.Limit:
                        slot.Limit = GetInt();
                        break;

                    default:
                        throw GetException("unexpected line in TimeSlot");
                    }
                }
                ts.list.Add(slot);
            }
            return(ts);
        }
        public async Task <TimeSlots> GetAppointmentSlots()
        {
            var appointments = await _appointmentRepository.GetAppointmentsCurrentDay();

            var freeSlots           = new List <TimeBlock>();
            var orderedAppointments = appointments.OrderBy(a => a.StartTime).ToArray();

            for (int i = 0; i < orderedAppointments.Length - 1; i++)
            {
                freeSlots.Add(new TimeBlock()
                {
                    StartTime = orderedAppointments[i].EndTime, EndTime = orderedAppointments[i + 1].StartTime
                });
            }

            var firstAppointment = orderedAppointments.First();
            var lastAppointment  = orderedAppointments.Last();

            if (firstAppointment.StartTime.Hour > 8)
            {
                freeSlots.Add(new TimeBlock()
                {
                    StartTime = firstAppointment.Today.AddHours(8), EndTime = firstAppointment.StartTime
                });
            }

            if (lastAppointment.EndTime.Hour < 18)
            {
                freeSlots.Add(new TimeBlock()
                {
                    StartTime = lastAppointment.EndTime, EndTime = lastAppointment.Today.AddHours(18)
                });
            }

            var appointmentSlots = new TimeSlots();

            foreach (var item in appointments.OrderBy(x => x.StartTime))
            {
                appointmentSlots.UsedSlots.Add($"{item.StartTime.ToShortTimeString()} - {item.EndTime.ToShortTimeString()}");
            }

            foreach (var item in freeSlots.OrderBy(x => x.StartTime))
            {
                appointmentSlots.AvailableSlots.Add($"{item.StartTime.ToShortTimeString()} - {item.EndTime.ToShortTimeString()}");
            }

            return(appointmentSlots);
        }
Example #22
0
 public void Output(StringBuilder sb, TimeSlots ts)
 {
     if (ts.list.Count == 0)
     {
         return;
     }
     AddValueCk(0, sb, "TimeSlotLockDays", ts.TimeSlotLockDays);
     AddValueNoCk(0, sb, "TimeSlots", "");
     foreach (var c in ts.list)
     {
         AddValueCk(1, sb, c.Description);
         AddValueCk(2, sb, "Time", c.Time.ToString2("t"));
         AddValueCk(2, sb, "DayOfWeek", c.DayOfWeek);
         AddValueCk(2, sb, "Limit", c.Limit);
     }
     sb.AppendLine();
 }
        public bool CreateTimeSlot(TimeSlot timeSlot)
        {
            bool isError = false;

            try
            {
                db.addTimeSlot(timeSlot);
            }
            catch (Exception ex)
            {
                isError = true;
                Console.WriteLine(ex);
                Console.WriteLine("Failed to update the Database ---  check error ABOVE");
            }
            TimeSlots.Add(timeSlot);
            return(isError);
        }
        public bool DeleteItem()
        {
            bool isError = false;

            try
            {
                db.deleteTimeSlot(this.SelectedTimeslot);
            }
            catch (Exception ex)
            {
                isError = true;
                Console.WriteLine(ex);
                Console.WriteLine("Failed to update the Database ---  check error ABOVE");
            }
            TimeSlots.Remove(this.SelectedTimeslot);
            return(isError);
        }
 public static Settings SetFakeSettings(int?regType, int orgId)
 {
     if (regType == RegistrationTypeCode.ChooseVolunteerTimes)
     {
         var m         = new Settings();
         var timeSlots = new TimeSlots();
         var ts1       = new TimeSlots.TimeSlot()
         {
             DayOfWeek = 0, Name = "MockTimeSlot", Time = System.DateTime.Now
         };
         timeSlots.list.Add(ts1);
         m.TimeSlots = timeSlots;
         m.OrgId     = orgId;
         return(m);
     }
     return(null);
 }
        public ActionResult Create(DateTime date, TimeSlots time, int Id, int time1)
        {
            string currentUserId = User.Identity.GetUserId();

            var c = db.Appointments.Where(x => x.PatientState.PatientId == currentUserId && x.ClinicId == Id && x.DayofApp == date).ToList();

            if (c.Count >= 1)
            {
                return(RedirectToAction("Details", "Home", new { ClinicId = Id, be = 1 }));
            }
            ViewBag.ClinicId = Id;
            ViewBag.Clinic   = db.Clinics.Find(Id).ClinicName;
            ViewBag.date     = date.ToString("dddd, dd MMMM yyyy");
            ViewBag.time     = time.GetDisplayName();
            ViewBag.timeid   = time1;

            return(View());
        }
        public void StartEdit(PracticeRoutine practiceRoutine)
        {
            this.practiceRoutine = practiceRoutine ?? throw new ArgumentNullException("PracticeRoutine must be provided.");
            LifeCycleState       = practiceRoutine.Id > 0 ? EntityLifeCycleState.AsExistingEntity : EntityLifeCycleState.AsNewEntity;

            if (TimeSlots != null)
            {
                TimeSlots.ListChanged -= (s, e) => RaisePropertyChanged(() => TotalTimeDisplay);
                TimeSlots.Clear();
            }

            foreach (var timeSlot in practiceRoutine)
            {
                TimeSlotViewModel timeSlotViewModel = new TimeSlotViewModel(timeSlot);
                TimeSlots.Add(timeSlotViewModel);
            }

            TimeSlots.ListChanged += (s, e) => RaisePropertyChanged(() => TotalTimeDisplay);
        }
Example #28
0
        private void add_timeslot_btn_Click(object sender, RoutedEventArgs e)
        {
            TimeSlots ts = new TimeSlots();

            ts.starting = timeslots_txtbx1.Text;
            ts.ending   = timeslots_txtbx2.Text;

            String startTime = timeslots_txtbx1.Text;
            String endTime   = timeslots_txtbx2.Text;
            String fullTime  = startTime + " - " + endTime;

            timeSlots_grid.Items.Add(ts);

            getstartTimes.Add(startTime + ",");
            getendTimes.Add(endTime + ",");
            getfullTimes.Add(fullTime);

            timeslots_txtbx1.Clear();
            timeslots_txtbx2.Clear();
        }
        public ActionResult Create([Bind(Include = "TimeSlotId,SlotTime")] TimeSlots timeSlots)
        {
            if (ModelState.IsValid)
            {
                if (BookingLogic.CheckITimeSlot(timeSlots) == false)
                {
                    // TODO Check if time slot exists
                    db.TimeSlots.Add(timeSlots);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ModelState.AddModelError("", "You can not add the same slot more than once");
                    return(View(timeSlots));
                }
            }

            return(View(timeSlots));
        }
        private void Delete()
        {
            if (SelectedItem is TimeSlotViewModel)
            {
                if (dialogService.YesNoPrompt("Delete Timeslot", "Sure you want to delete this time slot and all of its contents?"))
                {
                    practiceRoutine.Remove((SelectedItem as TimeSlotViewModel).TimeSlot);
                    TimeSlots.Remove(SelectedItem as TimeSlotViewModel);
                }
            }
            else
            {
                if (dialogService.YesNoPrompt("Remove Exercise", "Sure you want to remove this exercise from the timeslot?"))
                {
                    var exerciseViewModel = SelectedItem as TimeSlotExerciseViewModel;
                    var timeSlotViewModel = exerciseViewModel.TimeSlotViewModel;

                    timeSlotViewModel.TimeSlot.Remove(exerciseViewModel.TimeSlotExercise);
                    timeSlotViewModel.Remove(exerciseViewModel);
                }
            }
        }