public void AddProtocol(int studentID, string value, string hoursTotal, int subjectID, DateTime date) { int hours = Int32.Parse(hoursTotal); Protocol protocol = new Protocol(); protocol.StudentID = studentID; protocol.HoursTotal = hours; switch (value) { case "Present": protocol.HoursPresent = hours; protocol.HoursVirtual = 0; break; case "Virtual": protocol.HoursPresent = 0; protocol.HoursVirtual = hours; break; case "Absent": protocol.HoursPresent = 0; protocol.HoursVirtual = 0; break; } if (date == DateTime.Now.Date) { protocol.Date = DateTime.Now.Date; } else { protocol.Date = date; } protocol.SubjectID = subjectID; Protocol protocolobj; protocolobj = context.Protocols.FirstOrDefault(p => p.Date == date && p.SubjectID == subjectID && p.StudentID == studentID); // && p.HoursPresent == protocol.HoursPresent && p.HoursVirtual == protocol.HoursVirtual if (protocolobj == null) { context.Add(protocol); context.SaveChanges(); } else if (protocolobj != null) { DeleteProtocol(protocolobj); context.Add(protocol); context.SaveChanges(); } }
public void AddStudentSubject(StudentsSubjects ss) { context.Add(ss); context.SaveChanges(); }
public void AddSubject(Subject subject) { context.Add(subject); context.SaveChanges(); }