From fdfa48d9b932d76ca0f8fa092415caf7e739fe1b Mon Sep 17 00:00:00 2001 From: Userok Date: Mon, 21 Oct 2024 15:07:01 +0300 Subject: [PATCH] One --- .vs/slnx.sqlite | Bin 172032 -> 172032 bytes Zurnal/Domain/UseCase/UseCasePresence.cs | 46 +++++++---------------- 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/.vs/slnx.sqlite b/.vs/slnx.sqlite index 015932d077b4920d4653eb25c68983ec62ac9744..ea9ac80d56487d02174b4909e6fd43440f2319cb 100644 GIT binary patch delta 1752 zcmZ`(PfR0K7=J_C*O{SoN_VC$ZI?n3yOl7u_j1xD`fNU?0Y<*crS(Co{hEMi>ods*E&t`fr!%0xMIwj zW|~!f7xDlADC_}Yuf=9I1xa*`GXKpE(Oa|kU5dAcymR;5-Ur?q=5hk>4k-}iIS#(I z_IkbfrqNI<+M0>!$Ty6-&Yt}G{lr(tN5LWl5@4acTQvzLy$nGg!$Ms%r{v5$fkX2U z#4vnCt7)pCL4v2|Aedn|c=e#Et2KF{R^L)<>jv82;J7?-LVqnxd+dtnrOVkK`%9jI zpo9a_%C$r{^&Fl?Y$-lX|4T1AY?|6mRW~UdEI@Dpv%xUMW?q1xY9;*mn%q%(Vlgpp z7nJgyjZG46p~-WNaRf*2FDBZYKU<8Z?G({52!?QpvR2j0ntmWx3?K1N=OCE3%0Iai z3lK1sb<{zd8;?MSC^)FJpB6^>#v=`-O5C@Nj*lq*TNqt8p}wk#*56z`037;`~SN?~z( z*Jx-Jd&ka%oLVA6ZY(A4+7V(Bf-s(+qHP`QQqPNn5TtS6>xS0EzarizFOmYEv^by>iZ_KLNoAc3EiF4;oKN5$X?F({@VW+);b)#z5o438BU?c!R0-KiV6}6_| zTR|<7(76kK5+M3JrbsVB9R0W)iP)|6`XK1V8P^xPNDTUWIph!w^HvWmB>hpBAm{98 zed`9rB-UY|)c4h@PT>n)e86xHi!B9%(23vba1=c_o@1RS#nmXA4_D&O6e2FH3!rb# zsM$v{pXe%!T{sjUN#`|^$X*5)u}SGf%z3 z3hR;>>+}{|-&|eth>HIv5dIYY5PtLD5`Ga*{Xh6`w#4gi_<6UBV-&XwFvZp#{R0Ln ryaf0RVjH-M)Y@r$$_+=|dG3G8aBc}Wb>1x;-Y*<7Ul$I$z8n4*7Z^jH delta 1521 zcmZuxPfQb87=HuK>vSlcQaWvEE2ULZyTp;M3Rpp)ph!xw>*`_E5KDcs#WJm(!9rv6;&$MvOVeV(7>m_xL7XbjgbOjh=Qa6RDlAs5Vl{-?wEFr;X#glTo6%#pA+HCqv1#_OBm~g!V$P zgS5z@lA1&6qEggcCf|%De}rJvZ2xIF?6JW_YSWIET{b%0i~pbK+x*|R2ag=>+0Wu} z1%kb#)TzaqS|}?8O+&h-6br>)5#uPkH|=vW6vJ$MfXb138jWKF?+?s4h7Bb*jq75l zysOc!xUC&O&n9`=0e{RUM7mPCi5C1R8}OZ*)2gVb%xe{u8fhAX2d0RTbaiGbdX=tx zaR>rr|Hjem;v8dck3oO5>L?gu?whqchS;0>Ag{)a}m2;@f(48F+ z^pi69w;37V&u!aq;6cvz;&m>5oHq1tmE^VShGgroHO$Fk0pC`UEPzwfotDM2*V@0s zs$SABvlH3T20@Ho+-gND>6O}LhutvffgnmkQbp3 zO(Yd;q|!{YU>ir85LCIOQ6hOK%*Qk%z5-ax&lvOh9(Lvr~1TMUrF9fFWpHmaWB(LO>euu0k{(Y_5c6? diff --git a/Zurnal/Domain/UseCase/UseCasePresence.cs b/Zurnal/Domain/UseCase/UseCasePresence.cs index f6ddb9e..2c84b9e 100644 --- a/Zurnal/Domain/UseCase/UseCasePresence.cs +++ b/Zurnal/Domain/UseCase/UseCasePresence.cs @@ -1,56 +1,38 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace Zurnal.Domain.UseCase +namespace Zurnal.Presence { internal class UseCasePresence { - private Dictionary> attendanceRecords; + private List attendanceRecords; - public UseCasePresence() + public UseCasePresence(List attendanceRecords) { - attendanceRecords = new Dictionary>(); + this.attendanceRecords = attendanceRecords; } - public void MarkAttendance(string group, DateTime date) + public List GetAttendanceByGroup(string groupNumber) { - if (!attendanceRecords.ContainsKey(group)) - { - attendanceRecords[group] = new List(); - } - attendanceRecords[group].Add(date); + return attendanceRecords.Where(record => record.GroupNumber == groupNumber).ToList(); } - public List GetAttendanceByGroup(string group) + public List GetAttendanceByGroupAndDate(string groupNumber, DateTime date) { - if (attendanceRecords.ContainsKey(group)) - { - return attendanceRecords[group]; - } - return new List(); + return attendanceRecords.Where(record => record.GroupNumber == groupNumber && record.Date.Date == date.Date).ToList(); } - public List GetAttendanceByGroupAndDate(string group, DateTime date) + public void MarkUserAsAbsent(string groupNumber, int firstLesson, int lastLesson, DateTime date) { - if (attendanceRecords.ContainsKey(group)) + foreach (var lesson in Enumerable.Range(firstLesson, lastLesson - firstLesson + 1)) { - return attendanceRecords[group].Where(d => d.Date == date.Date).ToList(); - } - return new List(); - } - - public void MarkUserAsAbsent(string group, DateTime startDate, DateTime endDate) - { - if (attendanceRecords.ContainsKey(group)) - { - for (DateTime date = startDate; date <= endDate; date = date.AddDays(1)) + var record = attendanceRecords.FirstOrDefault(r => r.GroupNumber == groupNumber && r.LessonNumber == lesson && r.Date.Date == date.Date); + if (record != null) { - attendanceRecords[group].Remove(date); + record.IsPresent = false; } } } } -} +} \ No newline at end of file