public static Entities.StudentParentContact CreateStudentParentContact(StudentParentContactModelDataCRUD model, int userId) { using (var context = DataContext.GetContext()) { Debug.Assert(model.DateOfContact != null, "model.DateOfContact != null"); Debug.Assert(model.TimeOfContact != null, "model.TimeOfContact != null"); Debug.Assert(model.StudentParentId != null, "model.StudentParentId != null"); var result = new Entities.StudentParentContact { CreatedBy = userId, CreatedOn = DateTime.Now, LastModifiedOn = DateTime.Now, LastModifiedBy = userId, ContactMade = model.ContactMade, ContactNotes = string.IsNullOrEmpty(model.ContactNotes) ? string.Empty : model.ContactNotes , ContactTime = Misc.CombineDateAndTime(model.DateOfContact.Value, model.TimeOfContact.Value), StudentParentId = model.StudentParentId.Value }; context.StudentParentContacts.AddObject(result); context.SaveChanges(); return result; } }