public ActionResult Familiar(Guid id) { AssayMaterialEntity assayMaterialEntity = assayReposity.AssayMaterials.FirstOrDefault(a => a.StudentID == id); if (assayMaterialEntity == null) { assayReposity.SaveAssayMaterial(new AssayMaterialEntity { StudentID = id }); assayMaterialEntity = assayReposity.AssayMaterials.FirstOrDefault(a => a.StudentID == id); } StudentInfoEntity studentInfo = assayReposity.StudentsInfo.FirstOrDefault(s => s.StudentID == id); return(View(new StudentAssayMaterialViewModel { AssayMaterial = assayMaterialEntity, StudentInfo = studentInfo })); }