public SaveMap BeforeSaveEntities(SaveMap saveMap) { var unAuthorizedMaps = saveMap.Where(map => map.Key != _tWg && map.Key != _tFacComment && map.Key != _tFacStratResp && map.Key != _tFacSpResp && map.Key != _tStudCommentFlag && map.Key != _tFacCommentFlag) .ToList(); //.Select(map => map.Key); saveMap.RemoveMaps(unAuthorizedMaps); var courseMonitorEntities = saveMap.MonitorCourseMaps()?.ToList(); //if (courseMonitorEntities != null) ProcessCourseMonitoredMaps(courseMonitorEntities); var workGroupMonitorEntities = saveMap.MonitorWgMaps()?.ToList(); //if (workGroupMonitorEntities != null) ProcessWorkGroupMonitoredMaps(workGroupMonitorEntities); //moved processing for monitored entities to monitoredguard if (courseMonitorEntities != null || workGroupMonitorEntities != null) { var monitoredGuard = new MonitoredGuard(ctxManager); if (courseMonitorEntities != null) { monitoredGuard.ProcessCourseMonitoredMaps(courseMonitorEntities); } if (workGroupMonitorEntities != null) { monitoredGuard.ProcessFacultyWorkGroupMonitoredMaps(workGroupMonitorEntities); } } if (saveMap.ContainsKey(_tWg)) { var workGroupMap = ProcessWorkGroup(saveMap[_tWg]); saveMap.MergeMap(workGroupMap); } if (saveMap.ContainsKey(_tFacComment)) { ProcessComments(saveMap[_tFacComment]); } saveMap.AuditMap(loggedInUser.PersonId); saveMap.SoftDeleteMap(loggedInUser.PersonId); return(saveMap); }
public SaveMap BeforeSaveEntities(SaveMap saveMap) { var unAuthorizedMaps = saveMap.Where(map => map.Key != tStudComment && map.Key != tSpResponse && map.Key != tStudInGroup && map.Key != tStratResponse && map.Key != tStudCommentFlag) .ToList(); saveMap.RemoveMaps(unAuthorizedMaps); //Process any monitored entities to see if saves are allowed. var courseMonitorEntities = saveMap.MonitorCourseMaps()?.ToList(); var workGroupMonitorEntities = saveMap.MonitorWgMaps()?.ToList(); if (courseMonitorEntities != null || workGroupMonitorEntities != null) { var monitorGuard = new MonitoredGuard(ctxManager); if (courseMonitorEntities != null) { monitorGuard.ProcessCourseMonitoredMaps(courseMonitorEntities); } if (workGroupMonitorEntities != null) { monitorGuard.ProcessStudentWorkGroupMonitoredMaps(workGroupMonitorEntities); } } //Process studInGroup to ensure that only the logged student' is being handled. if (saveMap.ContainsKey(tStudInGroup)) { var infos = (from info in saveMap[tStudInGroup] let sig = info.Entity as CrseStudentInGroup where sig != null && sig.StudentId == loggedInUserId where info.EntityState == EntityState.Modified where info.OriginalValuesMap.ContainsKey("HasAcknowledged") select info).ToList(); if (infos.Any()) { foreach (var info in infos) { info.OriginalValuesMap = new Dictionary <string, object>() { { "HasAcknowledged", null } }; } saveMap[tStudInGroup] = infos; } else { saveMap.Remove(tStudInGroup); } } if (saveMap.ContainsKey(tStudComment)) { var newComments = saveMap[tStudComment] .Where(info => info.EntityState == EntityState.Added) .Select(info => info.Entity) .OfType <StudSpComment>() .ToList(); foreach (var comment in newComments) { comment.CreatedDate = DateTime.UtcNow; } } saveMap.AuditMap(loggedInUserId); saveMap.SoftDeleteMap(loggedInUserId); return(saveMap); }