public void Create(CallLogModel callLog) { if (!UpdateDatabase) { var first = GetAll().OrderByDescending(e => e.StudentID).FirstOrDefault(); var id = (first != null) ? first.StudentID : 0; GetAll().Insert(0, callLog); } else { var entity = new CallLog(); entity.CallID = callLog.CallID; entity.StudentID = callLog.StudentID; entity.UserID = callLog.UserID; entity.LanguageSpokenID = callLog.LanguageSpokenID == 0 ? 1 : callLog.LanguageSpokenID; entity.LanguageSpokenOther = callLog.LanguageSpokenOther; entity.CallStart = callLog.CallStart; entity.CallEnd = callLog.CallEnd; entity.ParentParticipation = callLog.ParentParticipation; entity.CallDropped = callLog.CallDropped; entity.CallTransferred = callLog.CallTransferred; entity.PostTestGiven = callLog.PostTestGiven; entity.SubjectID = callLog.SubjectID; entity.SkillAssessedNotes = callLog.SkillAssessedNotes; entity.SessionEvalNotes = callLog.SessionEvalNotes; entity.EvalStartID = callLog.EvalStartID; entity.EvalEndID = callLog.EvalEndID; entity.Textbook = callLog.Textbook; entity.Worksheet = callLog.Worksheet; entity.Stoodle = callLog.Stoodle; entity.ImageShare = callLog.ImageShare; entity.Chat = callLog.Chat; entity.GoogleDocs = callLog.GoogleDocs; entity.PrizeGiven = callLog.PrizeGiven; entity.PrizeID = callLog.PrizeID; entity.IsLocked = callLog.IsLocked; entity.BeatMath = callLog.BeatMath; entity.PrizeStudentName = callLog.PrizeStudentName; entity.PrizeTeacherName = callLog.PrizeTeacherName; entities.CallLogs.Add(entity); entities.SaveChanges(); callLog.CallID = entity.CallID; } }
public void Update(CallLogModel callLog) { if (!UpdateDatabase) { var target = One(e => e.CallID == callLog.CallID); if (target != null) { target.CallID = callLog.CallID; target.StudentID = callLog.StudentID; target.UserID = callLog.UserID; target.LanguageSpokenID = callLog.LanguageSpokenID == 0 ? 1 : callLog.LanguageSpokenID; target.LanguageSpokenOther = callLog.LanguageSpokenOther; target.CallStart = callLog.CallStart; target.CallEnd = GetEndTime(callLog.CallEnd, callLog.CallStart); target.ParentParticipation = callLog.ParentParticipation; target.CallDropped = callLog.CallDropped; target.CallTransferred = callLog.CallTransferred; target.PostTestGiven = callLog.PostTestGiven; target.SubjectID = callLog.SubjectID; target.SkillAssessedNotes = callLog.SkillAssessedNotes; target.SessionEvalNotes = callLog.SessionEvalNotes; target.EvalStartID = callLog.EvalStartID; target.EvalEndID = callLog.EvalEndID; target.Textbook = callLog.Textbook; target.Worksheet = callLog.Worksheet; target.Stoodle = callLog.Stoodle; target.ImageShare = callLog.ImageShare; target.Chat = callLog.Chat; target.GoogleDocs = callLog.GoogleDocs; target.PrizeGiven = callLog.PrizeGiven; target.PrizeID = callLog.PrizeID; target.IsLocked = callLog.IsLocked; target.BeatMath = callLog.BeatMath; target.PrizeStudentName = callLog.PrizeStudentName; target.PrizeTeacherName = callLog.PrizeTeacherName; } } else { var entity = new CallLog(); entity.CallID = callLog.CallID; entity.StudentID = callLog.StudentID; entity.UserID = callLog.UserID; entity.LanguageSpokenID = callLog.LanguageSpokenID == 0 ? 1 : callLog.LanguageSpokenID; entity.LanguageSpokenOther = callLog.LanguageSpokenOther; entity.CallStart = callLog.CallStart; entity.CallEnd = GetEndTime(callLog.CallEnd, callLog.CallStart); entity.ParentParticipation = callLog.ParentParticipation; entity.CallDropped = callLog.CallDropped; entity.CallTransferred = callLog.CallTransferred; entity.PostTestGiven = callLog.PostTestGiven; entity.SubjectID = callLog.SubjectID; entity.SkillAssessedNotes = callLog.SkillAssessedNotes; entity.SessionEvalNotes = callLog.SessionEvalNotes; entity.EvalStartID = callLog.EvalStartID; entity.EvalEndID = callLog.EvalEndID; entity.Textbook = callLog.Textbook; entity.Worksheet = callLog.Worksheet; entity.Stoodle = callLog.Stoodle; entity.ImageShare = callLog.ImageShare; entity.Chat = callLog.Chat; entity.GoogleDocs = callLog.GoogleDocs; entity.PrizeGiven = callLog.PrizeGiven; entity.PrizeID = callLog.PrizeID; entity.IsLocked = callLog.IsLocked; entity.BeatMath = callLog.BeatMath; entity.PrizeStudentName = callLog.PrizeStudentName; entity.PrizeTeacherName = callLog.PrizeTeacherName; entities.CallLogs.Attach(entity); entities.Entry(entity).State = EntityState.Modified; entities.SaveChanges(); } }