public Block Handle(CreateNextBlock action) { var previousBlock = _blockRepository.Get(action.ActionAgainst.Id); action.ActionAgainst = new Block { CreatedDateTime = DateTime.Now, MinutesPerClass = previousBlock.MinutesPerClass, NumberOfClasses = previousBlock.NumberOfClasses, ClassCapacity = previousBlock.ClassCapacity, Name = previousBlock.Name, Teachers = new List <Teacher>(previousBlock.Teachers), StartDate = previousBlock.StartDate.AddWeeks(previousBlock.NumberOfClasses), Room = previousBlock.Room, IsInviteOnly = previousBlock.IsInviteOnly }; action.ActionAgainst.EndDate = action.ActionAgainst.StartDate .AddMinutes(action.ActionAgainst.MinutesPerClass) .AddWeeks(action.ActionAgainst.NumberOfClasses - 1); var createdBlock = _blockRepository.Create(action.ActionAgainst); createdBlock.Classes = new CreateClassesForBlock(_classRepository, createdBlock) .Do() .ToList(); if (createdBlock.Room.IsNotNull()) { createdBlock = new ClassRoomChangerForBlock(_classRepository, createdBlock, createdBlock.Room).Do(); } return(createdBlock); }
public Block Handle(CreateBlock action) { action.ActionAgainst.EndDate = action.ActionAgainst.StartDate .AddMinutes(action.ActionAgainst.MinutesPerClass) .AddWeeks(action.ActionAgainst.NumberOfClasses - 1); action.ActionAgainst.StartDate = action.ActionAgainst.StartDate.ToUniversalTime(); action.ActionAgainst.EndDate = action.ActionAgainst.EndDate.ToUniversalTime(); var createdBlock = _blockRepository.Create(action.ActionAgainst); createdBlock.Classes = new CreateClassesForBlock(_classRepository, createdBlock) .Do() .ToList(); if (action.ActionAgainst.Room.IsNotNull()) { createdBlock.Room = _roomRepository.Get(action.ActionAgainst.Room.Id); createdBlock = new ClassRoomChangerForBlock(_classRepository, createdBlock, createdBlock.Room).Do(); createdBlock = _blockRepository.Update(createdBlock); } return(createdBlock); }
public Block Handle(ChangeBlockRoom action) { var block = _blockRepository.Get(action.ActionAgainst.Id); var room = _roomRepository.Get(action.ActionAgainst.Room.Id); block = new ClassRoomChangerForBlock(_classRepository, block, room).Do(); block.Room = room; return(_blockRepository.Update(block)); }