public void RemoveEvent(EventDomain e)
        {
            var eventToDelete = db.Events.Where(x => x.Id == e.Id).FirstOrDefault();

            db.Events.Remove(eventToDelete);
            db.SaveChanges();
        }
Exemple #2
0
        public void GetEvent_GettingNotExistingEvent_ShouldThrowException()
        {
            //Arrange
            var mockEventRepo = new Mock <IEventRepository>();
            var eventDomain   = new EventDomain(mockEventRepo.Object, null, null, null);

            mockEventRepo
            .Setup(evrep => evrep.GetWholeEvent(It.IsAny <int>()))
            .Returns(() => null);

            // Act and Assert
            Assert.Throws <NotFoundException>(() => eventDomain.GetEvent(123));
            mockEventRepo.Verify(evrep => evrep.GetWholeEvent(It.IsAny <int>()), Times.Once());
        }
Exemple #3
0
        public void UpdateCalendarEventSeries_UpdateNotExistingEvents_ShouldThrowException()
        {
            //Arrange
            int            userId        = 0;
            EventViewModel actualVM      = new EventViewModel();
            var            mockEventRepo = new Mock <IEventRepository>();

            mockEventRepo
            .Setup(x => x.UpdateCalendarEventSeries(It.IsAny <Event>()))
            .Verifiable();
            var eventDomain = new EventDomain(mockEventRepo.Object, null, null, null);

            // Act and Assert
            Assert.Throws <NotFoundException>(() => eventDomain.UpdateCalendarEventSeries(actualVM, userId));
            mockEventRepo.Verify(evrep => evrep.UpdateCalendarEventSeries(It.IsAny <Event>()), Times.Never());
        }
Exemple #4
0
        public void DeleteCalendarEvent_DeleteNotExistingEvent_ShouldThrowException()
        {
            //Arrange
            int            userId        = 0;
            EventViewModel actualVM      = new EventViewModel();
            var            mockEventRepo = new Mock <IEventRepository>();

            mockEventRepo
            .Setup(evrep => evrep.DeleteCalendarEvent(It.IsAny <int>()))
            .Returns(() => null)
            .Verifiable();
            var eventDomain = new EventDomain(mockEventRepo.Object, null, null, null);

            // Act and Assert
            Assert.Throws <NotFoundException>(() => eventDomain.DeleteCalendarEvent(actualVM.Id, userId));
            mockEventRepo.Verify(evrep => evrep.DeleteCalendarEvent(It.IsAny <int>()), Times.Never());
        }
        private static EventDto FillViewModel(EventDomain e)
        {
            var eventDto = new EventDto()

            {
                Id            = e.Id,
                Title         = e.Title,
                StartDateTime = e.StartDateTime,
                Location      = e.Location,
                Description   = e.Description,
                Duration      = e.Duration,
                IsPublic      = e.IsPublic,
                Author        = e.Author,
                InvitedEmails = e.InviteByEmail,
                OtherDetails  = e.OtherDetails,
                AuthorId      = e.Author.Id,
                //  Comments = e.Comments.AsQueryable().Select(CommentViewModel.ViewModel),
            };

            return(eventDto);
        }
 public void AddEvent(EventDomain e)
 {
     db.Events.Add(e);
     db.SaveChanges();
 }
 public EventController()
 {
     this.eventDomain = new EventDomain();
 }
Exemple #8
0
 public AdministrationController(AdminDomain adminDomain, EventDomain eventDomain)
 {
     this.AdminDomain = adminDomain;
     this.EventDomain = eventDomain;
 }