private void LoadRoomCalendar(Room room) { if (room != null) { string roomKey = String.Format("{0}|{1}", room.Area.area_name, room.room_name); if (!roomCalendars.ContainsKey(roomKey)) { CalendarRoom r = new CalendarRoom(); List <Entry> entries = Database.GetFutureAppointments(room); r.StartTime = CalendarStart; r.EndTime = CalendarEnd; r.Name = room.room_name; foreach (Entry e in entries) { CalendarAppointment appt = new CalendarAppointment(); appt.BeverageService = e.coffee != ""; appt.Description = e.name; appt.Finish = Database.UnixTimeStampToDateTime(e.end_time); appt.FoodService = e.food_needed.HasValue ? e.food_needed.Value : false; appt.Location = e.Room.room_name; appt.Requestor = e.requestor; appt.Start = Database.UnixTimeStampToDateTime(e.start_time); r.Appointments.Add(appt); } roomCalendars.Add(roomKey, r); } } }
internal void FireAppointmentDoubleClicked(CalendarAppointment appointment) { if (this.AppointmentDoubleClicked != null) { this.AppointmentDoubleClicked(this, appointment); } }
public CalendarAppointment ReadICalAppointment(string appointment) { CalendarAppointment calendarAppointment = new CalendarAppointment(); calendarAppointment.Start = (Regex.Match(appointment, @"(?<=DTSTART([\S]*?):).\S*").Value).ParseDateFromICalString(); calendarAppointment.End = (Regex.Match(appointment, @"(?<=DTEND([\S]*?):).\S*").Value).ParseDateFromICalString(); calendarAppointment.Title = Regex.Match(appointment, @"(?<=SUMMARY:).*").Value; calendarAppointment.Description = Regex.Match(appointment, @"(?<=DESCRIPTION:).*").Value; calendarAppointment.RecurrenceRule = Regex.Match(appointment, @"(?<=RRULE:).*").Value; return(calendarAppointment); }
private void MonthView_OnDayDoubleClicked(object sender, CalendarDay e) { var calendar = (MonthView)sender; Debug.WriteLine("double clicked: {0:d}", (object)e.Date); var eventText = InputTextBox.Show("Bezeichnung:"); if (!string.IsNullOrEmpty(eventText)) { var appointment = new CalendarAppointment(e.Date, eventText); this.Appointments.Add(appointment); } }
public void TestCanInsertAPreviousAppointment() { var appointment = _validAppointment; var vehicle = new Vehicle(validRegistration); vehicle.Appointments.Add(appointment); var previousAppointmentEnd = appointment.DateRange.Start.AddDays(-1); var secondAppointment = new CalendarAppointment(validSummary, validLocation, new DateTimeSpan(previousAppointmentEnd, previousAppointmentEnd.AddDays(1))); vehicle.Appointments.Add(secondAppointment); Assert.AreEqual(2, vehicle.Appointments.Count()); }
private void MonthView_OnAppointmentDoubleClicked(object sender, CalendarAppointment e) { Debug.WriteLine("double clicked: {0:d} - {1}", (object)e.AppointmentDate, e.AppointmentText); }
public CalendarTimelineViewModel GetCalendarTimeline(DateTime date, Trust trust, int departmentId) { var model = new CalendarTimelineViewModel() { RequestDate = date, DepartmentId = departmentId }; if (trust == null) { model.IntervalNotDefined = true; return(model); } var allApts = repository.GetContext().PatientAppointments .Include(p => p.Patient)//This entity type can be changed when using this scheduler for other type entities .Where(p => p.DepartmentId == departmentId && p.AppointmentDateTime.Date.Equals(date.Date)); var appointments = allApts.Where(p => !p.IsArchived); var time = GetStartEndTime(trust, date.DayOfWeek); var appStartTime = DateTime.Parse(time.Item1); var appEndTime = DateTime.Parse(time.Item2); do { var appDateTime = date.AddHours(appStartTime.Hour).AddMinutes(appStartTime.Minute); var appModel = new CalendarAppointment { AppointmentTime = appStartTime.ToString("HH:mm"), AppointmentDateTime = appDateTime.ToString("dd/MM/yyyy HH:mm"), DisplayPropCount = 2 }; var app = appointments.FirstOrDefault(a => a.AppointmentDateTime == appDateTime); if (app != null) { appModel.EntityDetail = new SchedulerEntityDetail { AppointmentId = app.PatientAppointmentId, EntityId = app.PatientId ?? 0, EntityText = string.Format("{0} ({1}, {2})", app.Patient.GetDisplayName(), app.Patient.Gender != null? app.Patient.Gender.Name:"N/A", GetAge(app.Patient.DateOfBirth)), IconCss = "fa fa-user-plus" }; appModel.EntityDetail.DisplayProperties.Add("PAS", app.Patient.PasNumber); appModel.EntityDetail.DisplayProperties.Add("NHS", app.Patient.NhsNumber); } model.Appointments.Add(appModel); appStartTime = appStartTime.AddMinutes(trust.AppointmentIntervalMins); } while (appStartTime <= appEndTime); //Cancelled apts foreach (var apt in allApts.Where(p => p.IsArchived)) { var item = new SchedulerEntityDetail() { AppointmentId = apt.PatientAppointmentId, EntityId = apt.PatientId ?? 0, EntityText = string.Format("{0} ({1}, {2})", apt.Patient.GetDisplayName(), apt.Patient.Gender != null ? apt.Patient.Gender.Name : "N/A", GetAge(apt.Patient.DateOfBirth)), IconCss = "fa fa-user-plus", AppointmentTime = apt.AppointmentDateTime.ToString("HH:mm") }; item.DisplayProperties.Add("PAS", apt.Patient.PasNumber); item.DisplayProperties.Add("NHS", apt.Patient.NhsNumber); item.DisplayProperties.Add("Note", string.IsNullOrEmpty(apt.CancelNotes)?"N/A": apt.CancelNotes); model.CancelledAppointments.Add(item); } return(model); }
public void Setup() { _validDateRange = new DateTimeSpan(DateTime.Now, DateTime.Now.AddDays(1)); _validAppointment = new CalendarAppointment(validSummary, validLocation, _validDateRange); }
public ActionResult <Appointment> AddAppointment([FromBody] DTOAppointment dtoAppointment) { var claims = User.Claims; var userId = claims.FirstOrDefault(x => x.Type == "id")?.Value; if (userId != dtoAppointment.OwnerId.ToString()) { return(Unauthorized()); } using (var unit = _factory.GetUOF()) { try { var dbUser = unit.Users.GetEager(dtoAppointment.OwnerId); var startTime = StringToDateTime.Convert(dtoAppointment.StartTime); var endTime = StringToDateTime.Convert(dtoAppointment.EndTime); // Create appointment var appointment = new Appointment { Participants = new List <CalendarAppointment>(), StartTime = startTime, EndTime = endTime, Text = dtoAppointment.Text, Title = dtoAppointment.Title, MaxParticipants = dtoAppointment.MaxParticipants, OwnerId = dtoAppointment.OwnerId }; //Check if there is a spot in the calendar var occupiedTime = dbUser.Calendar.Appointments.Any(x => x.Appointment.StartTime <= appointment.StartTime && x.Appointment.EndTime >= appointment.StartTime); if (occupiedTime) { return(BadRequest(new { message = "Please pick a free spot in the calendar" })); } var calendarAppointment = new CalendarAppointment { Appointment = appointment, Calendar = dbUser.Calendar }; dbUser.Calendar.Appointments.Add(calendarAppointment); unit.Complete(); var res = new DTOAppointmentPrivate { Participants = new List <DTOSimpleUser>() }; var simpleUser = new DTOSimpleUser(); Mapper.Map(dbUser, simpleUser); res.Participants.Add(simpleUser); Mapper.Map(appointment, res); return(CreatedAtAction("GetAppointment", new { appointmentId = res.Id }, res)); } catch (Exception e) { Console.WriteLine(e); throw; } } }
public ActionResult <DTOAppointmentPrivate> AddUserToAppointment([FromBody] DTOId userId, Guid appointmentId) { using (var unit = _factory.GetUOF()) { try { var dbAppointment = unit.Appointments.GetEager(appointmentId); if (dbAppointment == null) { return(BadRequest(new { message = $"Appointment with id '{appointmentId}' did not exist" })); } var dbUser = unit.Users.GetEager(userId.Id); if (dbUser == null) { return(BadRequest(new { message = $"User with id '{userId.Id}' did not exist" })); } if (dbAppointment.MaxParticipants <= dbAppointment.Participants.Count) { return(BadRequest(new { message = "Appointment is full" })); } if (dbAppointment.Participants.Any(x => x.Calendar.User.NormalizedEmail == dbUser.NormalizedEmail)) { return(BadRequest(new { message = "User is already in the appointment" })); } var calendarAppointment = new CalendarAppointment { Appointment = dbAppointment, Calendar = dbUser.Calendar }; dbAppointment.Participants.Add(calendarAppointment); unit.Complete(); var res = new DTOAppointmentPrivate { Participants = new List <DTOSimpleUser>() }; foreach (var participant in dbAppointment.Participants) { var simpleUser = new DTOSimpleUser(); Mapper.Map(participant.Calendar.User, simpleUser); res.Participants.Add(simpleUser); } Mapper.Map(dbAppointment, res); return(CreatedAtAction("GetAppointment", new { appointmentId = res.Id }, res)); } catch (Exception e) { Console.WriteLine(e); throw; } } }