Created
July 7, 2019 20:36
-
-
Save ProximaB/1c25d037c14772a21816e637cab42d6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tmpRes = query.List<object[]>().Select(a => new { | |
EmployeeId = a[0].ToInt32(), | |
StudiesModeId = a[1].ToInt32Nullable(), | |
FormId = a[2].ToInt32Nullable() | |
}).ToArray(); | |
if (tmpRes != null && tmpRes.Count() > 0) | |
{ | |
var tmpGroupedRes = tmpRes.GroupBy(a => a.EmployeeId); | |
//all types or forms for each employee must have value or all of them must not have it - otherwise we throw an exception | |
if (!tmpGroupedRes.Any(a => a.All(b => b.StudiesModeId.HasValue || b.FormId.HasValue) || a.All(b => !b.StudiesModeId.HasValue && !b.FormId.HasValue))) | |
throw new Exception("Niespójne dane w pensum pracownika! Opcja 'tylko suma' nie daje możliwości wpisania godzin z podziałem na formy."); | |
result = tmpGroupedRes.Select(a => new { PracId = a.Key, TylkoSuma = !a.All(b => b.StudiesModeId.HasValue || b.FormId.HasValue) }) | |
.ToDictionary(a => a.PracId, a => a.TylkoSuma); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment