SHARE
TWEET

Untitled

a guest Jul 18th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tmpRes = query.List<object[]>().Select(a => new {
  2.     EmployeeId = a[0].ToInt32(),
  3.     StudiesModeId = a[1].ToInt32Nullable(),
  4.     FormId = a[2].ToInt32Nullable()
  5. }).ToArray();
  6.  
  7. if (tmpRes != null && tmpRes.Count() > 0)
  8. {
  9.     var tmpGroupedRes = tmpRes.GroupBy(a => a.EmployeeId);
  10.     //all types or forms for each employee must have value or all of them must not have it - otherwise we throw an exception
  11.     if (!tmpGroupedRes.Any(a => a.All(b => b.StudiesModeId.HasValue || b.FormId.HasValue) || a.All(b => !b.StudiesModeId.HasValue && !b.FormId.HasValue)))
  12.         throw new Exception("Niespójne dane w pensum pracownika! Opcja 'tylko suma' nie daje możliwości wpisania godzin z podziałem na formy.");
  13.     result = tmpGroupedRes.Select(a => new { PracId = a.Key, TylkoSuma = !a.All(b => b.StudiesModeId.HasValue || b.FormId.HasValue) })
  14.         .ToDictionary(a => a.PracId, a => a.TylkoSuma);
  15. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top