private void OnRoomAvailabilityListRemove(RoomAvailability entity) { SendPropertyChanging(null); entity.Room = null; SendPropertyChanged(null); }
private void OnRoomAvailabilityListAdd(RoomAvailability entity) { SendPropertyChanging(null); entity.Room = this; SendPropertyChanged(null); }
/// <summary> /// Handles the Click event of the _btnAddDates control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void _btnAddDates_Click(object sender, EventArgs e) { var startDate = (DateTime)_rdpStartDate.DbSelectedDate; var startTime = ((DateTime)_rtpStartTime.DbSelectedDate).TimeOfDay; var endDate = _rdpEndDate.DbSelectedDate; var endTime = ((DateTime)_rtpEndTime.DbSelectedDate).TimeOfDay; var days = _rcbDays.CheckedItems.Aggregate(String.Empty, (current, item) => current + (item.Value + ",")).TrimEnd(','); var isVald = GetIsValdAddDates(days, endDate, startDate, startTime, endTime); if (isVald == false) return; //Check for any overlap here var appointMentToAdd = new AppointmentTemporaryObj { AllDay = false, Days = days, EndDate = (DateTime?)endDate, EndTime = endTime, RoomId = RoomId, StartDate = startDate, StartTime = startTime }; var db = new UrbanDataContext(); var currentAvilList = db.Manager.RoomAvailability.GetByRoomID(RoomId).OrderByDescending(t => t.StartDate).ToList(); //Check if date to add is valid over existing range of dates. if (AppointmentTemporaryObj.DoesDateOverLap(appointMentToAdd, currentAvilList.ToAppointmentTempObject())) { WriteFeedBackMaster(FeedbackType.Error, "Date overlaps"); return; } var newAppointment = new RoomAvailability { AllDay = appointMentToAdd.AllDay, Days = appointMentToAdd.Days == String.Empty ? null : appointMentToAdd.Days, EndDate = appointMentToAdd.EndDate, EndTime = appointMentToAdd.EndTime, RoomID = RoomId, StartDate = appointMentToAdd.StartDate, StartTime = appointMentToAdd.StartTime }; db.RoomAvailability.InsertOnSubmit(newAppointment); db.SubmitChanges(); RebindGridAndScheduler(); }
/// <summary> /// Calculates the recurring from availble. /// </summary> /// <param name = "avail">The avail.</param> /// <param name = "endDate">The end date.</param> /// <returns></returns> private static IEnumerable<AppointmentObj> CalculateRecurringFromAvailble(RoomAvailability avail, DateTime endDate) { var dayList = ParseDayString(avail.Days ?? String.Empty); var apptList = new List<AppointmentObj>(); //recurring dates var days = 0; for (var date = avail.StartDate.Add(avail.StartTime); date.Date < endDate; date = date.AddDays(1)) { if (dayList.Contains(date.DayOfWeek)) //Handle day of the week recurring apptList.Add(new AppointmentObj("Available", avail.StartDate.Add(avail.StartTime).AddDays(days), avail.StartDate.Add(avail.EndTime).AddDays(days), "", "", "", avail.Room.UserID, false, avail.Id)); days++; } return apptList; }