コード例 #1
0
        /// <summary>
        /// Add staff atteneddent to event
        /// </summary>
        /// <param name="staff"></param>
        /// <param name="eventId"></param>
        /// <returns></returns>
        public bool AddStaffAttendentsToEvent(List<Staff> staff, int eventId)
        {
            if (staff.Count != 0 && eventId != 0)
            {
                foreach (var s in staff)
                {
                    var staffEventId = StaffEventsIdGeneration();

                    var eventModule = new StaffEvent
                    {
                        EventId = eventId,
                        StaffId = s.StaffId,
                        StaffEventId = staffEventId
                    };
                    _dBase.StaffEvents.Add(eventModule);
                    _dBase.SaveChanges();
                }
                return true;
            }
            return false;
        }
コード例 #2
0
        /// <summary>
        /// Staff added to events in general, no staff has to be adde to an event
        /// to be confirmed
        /// </summary>
        /// <param name="eventId"></param>
        /// <param name="staffId"></param>
        /// <returns></returns>
        public bool StaffEvent(int eventId, int staffId)
        {
            //as long as valid ids passed in attendee added
            if (eventId != 0 && staffId != 0)
            {
                //current staff allocation removed
                var idRecovery = _dBase.StaffEvents.SingleOrDefault(x => x.EventId == eventId);
                //Ids of current staff allocation recycled
                if (idRecovery != null)
                {
                    //recycled Id maintained
                    var recoveredId = new RecycledId
                    {
                        IdRecovered = idRecovery.StaffEventId,
                        TableName = "Staff Event",
                        DateAdded = DateTime.Now
                    };
                    _dBase.RecycledIds.Add(recoveredId);
                    _dBase.StaffEvents.Remove(idRecovery);
                    _dBase.SaveChanges();
                }

                //new staff attendee created
                var inviteId = StaffEventsIdGeneration();
                var staffEvent = new StaffEvent
                {
                    StaffEventId = inviteId,
                    StaffId = staffId,
                    EventId = eventId
                };
                _dBase.StaffEvents.Add(staffEvent);
                _dBase.SaveChanges();
                return true;
            }
            return false;
        }