public void CanCreateCalendarBooking() { DateTime start = DateTime.Now; DateTime end = start.AddHours(1); var cEvent = new CalendarBooking(start, end, _user.Id, _venue); Assert.Equal(cEvent.StartTime, start); Assert.Equal(cEvent.EndTime, end); }
public CalendarBooking GetTeacherCalendarByBookingId(int teacherId, int bookingId) { using (var dbContext = new DataAccess.TeachersAssistantDbContext()) { _unitOfWork.InitializeDbContext(dbContext); CalendarBooking calendarBooking = null; calendarBooking = _unitOfWork._calendarBookingRepository.GetAll().SingleOrDefault(p => p.TeacherId == teacherId && p.BookingTimeId == bookingId); return(calendarBooking); } }
public void CalendarBookingsCanBePublished() { DateTime start = DateTime.Now; DateTime end = start.AddHours(1); var cEvent = new CalendarBooking(start, end, _user.Id, _venue); Assert.True(cEvent.PublishState == PublishState.Draft); Assert.True(cEvent.PublishDate == DateTime.MinValue); cEvent.Publish(); Assert.True(cEvent.PublishState == PublishState.Published); Assert.True(cEvent.PublishDate != DateTime.MinValue); }
public void DeleteTeacherCalendarByBooking(CalendarBooking teacherCalendar) { using (var dbContext = new DataAccess.TeachersAssistantDbContext()) { _unitOfWork.InitializeDbContext(dbContext); if (teacherCalendar.CalendarBookingId != null && teacherCalendar.CalendarBookingId > 0) { var booking = _unitOfWork._calendarBookingRepository.GetById((int)teacherCalendar.CalendarBookingId); _unitOfWork._calendarBookingRepository.Delete(booking); _unitOfWork.SaveChanges(); } } }
public void SaveOrUpdateCalendar(CalendarBooking calendarBk) { using (var dbContext = new DataAccess.TeachersAssistantDbContext()) { _unitOfWork.InitializeDbContext(dbContext); var calendarBooking = _unitOfWork._calendarBookingRepository.GetById((int)calendarBk.CalendarBookingId); calendarBooking.SubjectId = calendarBooking.SubjectId; if (calendarBk.ClassId > 0) { calendarBooking.ClassId = calendarBk.ClassId; } _unitOfWork._calendarBookingRepository.Update(calendarBooking); _unitOfWork.SaveChanges(); } }
public void ChangingEventPropertiesChangesPublishStateAndModifiedDate() { DateTime start = DateTime.Now; DateTime end = start.AddHours(1); var cEvent = new CalendarBooking(start, end, _user.Id, _venue); cEvent.Publish(); Assert.True(cEvent.PublishState == PublishState.Published); var lastModifiedDate = cEvent.LastModified; var venue = new Venue(); cEvent.Venue = venue; Assert.Equal(cEvent.PublishState,PublishState.Draft); var updatedLastModifiedDate = cEvent.LastModified; //Assert.True(updatedLastModifiedDate > lastModifiedDate); cEvent.Publish(); Assert.True(cEvent.PublishDate >= lastModifiedDate); Assert.Equal(cEvent.PublishState, PublishState.Published); cEvent.Venue = venue; Assert.Equal(cEvent.PublishState,PublishState.Published); Assert.Equal(cEvent.LastModified, updatedLastModifiedDate); }
public ActionResult Create(EventFormModel eventFormModel) { PopulateEventDropDowns(eventFormModel); if (ModelState.IsValid) { var rosterMembershipUser = (RosterMembershipUser) Membership.GetUser(); var domainUser = AutoMapper.Mapper.Map<RosterMembershipUser, User>(rosterMembershipUser); var venue = RavenSession.Load<Venue>(eventFormModel.VenueId); var newEvent = new CalendarBooking(eventFormModel.StartDate, eventFormModel.EndDate, domainUser.Id,venue); foreach (var staffmember in eventFormModel.SelectedStaff) { var user = RavenSession.Load<User>(staffmember); newEvent.AddStaff(user); } RavenSession.Store(newEvent); RavenSession.SaveChanges(); var regevents = CurrentEditSession.RegisteredEvents; } ModelState.Clear(); var day = new DateTime(eventFormModel.StartDate.Year, eventFormModel.StartDate.Month, eventFormModel.StartDate.Day); if (Request.IsAjaxRequest()) { if (ModelState.IsValid) return Json(new { FormattedDate = eventFormModel.StartDate.YmdFormat(), StartDate = day.ToString(CultureInfo.InvariantCulture), EndDate = day.AddDays(1).ToString(CultureInfo.InvariantCulture) }); return PartialView("Create", eventFormModel); } return RedirectToAction("Index", "Home"); }
public void SaveOrUpdateBooking(Teacher teacher, Student student, Subject subject, BookingTime bookingTime, string description) { using (var dbContext = new DataAccess.TeachersAssistantDbContext()) { _unitOfWork.InitializeDbContext(dbContext); var calendar = _unitOfWork._calendarBookingRepository.GetAll().SingleOrDefault(p => p.BookingTimeId == bookingTime.BookingTimeId); if (calendar == null) { var bookingTimes = new BookingTime { StartTime = bookingTime.StartTime, EndTime = bookingTime.EndTime }; _unitOfWork._bookingTimeRepository.Add(bookingTimes); _unitOfWork.SaveChanges(); calendar = new CalendarBooking { StudentId = (int)student.StudentId, SubjectId = (int)subject.SubjectId, TeacherId = (int)teacher.TeacherId, BookingTimeId = (int)bookingTimes.BookingTimeId, Description = description }; _unitOfWork._calendarBookingRepository.Add(calendar); _unitOfWork.SaveChanges(); } else { var bkTime = _unitOfWork._bookingTimeRepository.GetById((int)bookingTime.BookingTimeId); bkTime.StartTime = bookingTime.StartTime; bkTime.EndTime = bookingTime.EndTime; calendar.BookingTime = bkTime; calendar.Description = description; _unitOfWork.SaveChanges(); } } }
public void EditingEventRaisesModifiedEvent() { var start = DateTime.Now; var end = start.AddHours(1); var cEvent = new CalendarBooking(start, end, _user.Id, _venue); CalendarBooking modifiedBooking = null; DomainEvents.Register<BookingModifiedEvent>(p => modifiedBooking = p.ModifiedBooking); cEvent.EndTime = end.AddHours(1); Assert.Equal(modifiedBooking,cEvent); }
public void CalendarBookingsAreInDraftStateByDefault() { var cEvent = new CalendarBooking(DateTime.Now, DateTime.Now.AddHours(2), _user.Id, _venue); Assert.Equal(cEvent.PublishState,PublishState.Draft); }
public void PublishingRaisesPublishEvent() { var start = DateTime.Now; var end = start.AddHours(1); var cEvent = new CalendarBooking(start, end, _user.Id, _venue); CalendarBooking publishedBooking = null; DomainEvents.Register<BookingPublishedEvent>(p => publishedBooking = p.PublishedBooking); cEvent.Publish(); Assert.Equal(publishedBooking,cEvent); }