示例#1
0
        private List <EventStaffAssignment> AssignStaffToEvent(long eventId, long podId, long assignedByOrgRoleId, IEnumerable <EventStaffBasicInfoModel> eventStaff)
        {
            var savedAssignments = new List <EventStaffAssignment>();

            _eventStaffAssignmentRepository.DeleteFor(eventId);
            foreach (var staffAssignment in eventStaff)
            {
                var eventStaffAssignment = Mapper.Map <EventStaffBasicInfoModel, EventStaffAssignment>(staffAssignment);
                if (eventStaffAssignment.ActualStaffOrgRoleUserId <= 0)
                {
                    eventStaffAssignment.ActualStaffOrgRoleUserId = null;
                }
                eventStaffAssignment.EventId = eventId;
                eventStaffAssignment.PodId   = podId; //is this right, why are we saving pod with event assignment, maybe assigned to differnt pod?
                eventStaffAssignment.DataRecorderMetaData = new DataRecorderMetaData(assignedByOrgRoleId, DateTime.Now, null);
                savedAssignments.Add(_repository.Save(eventStaffAssignment));
            }
            return(savedAssignments);
        }
        public void DeleteFor_DeletesCorrectlyForValidEvent()
        {
            const int validEventId    = 2;
            var       staffAssignment = new EventStaffAssignment
            {
                ScheduledStaffOrgRoleUserId = 26,
                EventId              = validEventId,
                PodId                = 1,
                StaffEventRoleId     = 1,
                Notes                = "Should Be DELETED - Integration TEST",
                DataRecorderMetaData = new DataRecorderMetaData(1, new DateTime(2011, 1, 21), null)
            };

            _repository.Save(staffAssignment);
            _eventStaffAssignmentRepository.DeleteFor(validEventId);

            var actual = _eventStaffAssignmentRepository.GetForEvent(validEventId);

            Assert.AreEqual(0, actual.Count());
        }