Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement