public void AddActivity(int StudentId, int?GroupId, int?ClassroomId, TimeSpans TimeSpan, string Place, string Title, string content) { _context.TimeSpans.Add(TimeSpan); Activities act = new Activities { GroupId = GroupId, TimeSpanId = TimeSpan.TimeSpanId, ClassroomId = ClassroomId, Place = Place, Title = Title, ActivityContent = content, Cancelling = false, }; _context.Activities.Add(act); StudentsActivities sa = new StudentsActivities { StudentId = StudentId, ActivityId = act.ActivityId, Ignore = false, Alert = false }; _context.StudentsActivities.Add(sa); _context.SaveChanges(); }
public void DeleteActivity(int StudentId, int ActivityId) { StudentsActivities sa = _context.StudentsActivities.Include(a => a.Activity).First(a => a.StudentId == StudentId && a.ActivityId == ActivityId); Activities ac = sa.Activity; _context.Remove(sa); _context.Remove(ac); _context.SaveChanges(); }
public void AlertActivity(int StudentId, int ActivityId) { StudentsActivities sa = _context.StudentsActivities.First(a => a.StudentId == StudentId && a.ActivityId == ActivityId); if (sa.Alert == true) { throw new Exception("vec je Alertovan"); } sa.Alert = true; _context.SaveChanges(); }