/// <summary> /// studnet invitations for event created /// </summary> /// <param name="students"></param> /// <param name="eventId"></param> /// <returns></returns> public bool AddStudentInvitesToEvent(List<Student> students, int eventId) { if (eventId != 0) { //current invites selceted var allInvites = _dBase.StudentInvites.Where(x => x.EventId == eventId).ToList(); //current invites removed if (allInvites.Count > 0) { foreach (var i in allInvites) { var recycledId = new RecycledId { IdRecovered = i.StudentInviteId, DateAdded = DateTime.Now.AddSeconds(1), TableName = "Student Invite" }; _dBase.StudentInvites.Remove(i); _dBase.RecycledIds.Add(recycledId); _dBase.SaveChanges(); } } //new invited created foreach (var s in students) { //new invite id generated var studentInviteId = StudentInvitesIdGeneration(); //new student invite object created var studentInvite = new StudentInvite { EventId = eventId, StudentId = s.StudentId, StudentInviteId = studentInviteId, Attending = false }; //Invite added to databse _dBase.StudentInvites.Add(studentInvite); _dBase.SaveChanges(); } return true; } return false; }
/// <summary> /// Invitation of student to events that have been assigned on a /// room and not a module, as evemt with modules invitations handled /// by module event records /// </summary> /// <param name="eventId"></param> /// <param name="studentId"></param> /// <returns></returns> public bool StudentInvite(int eventId, int studentId) { if (eventId != 0 && studentId != 0) { //Id generated var inviteId = StudentInvitesIdGeneration(); var studentEvent = new StudentInvite { StudentInviteId = inviteId, StudentId = studentId, EventId = eventId, Attending = true }; //student Invite added _dBase.StudentInvites.Add(studentEvent); _dBase.SaveChanges(); return true; } return false; }