private void AddCleaning(Reservation rez, SqliteContext conn)
        {
            DateTime dateStart = rez.StartTime.Date;

            var clinings = conn.Cleanings.Where(p => p.IdRoom == rez.IdRoom).ToList();

            if (clinings.Any(p => p.CleanTime.Date == dateStart))
            {
                dateStart = dateStart.AddDays(1);
            }

            for (DateTime date = dateStart; date < rez.StopTime.Date; date = date.AddDays(1))
            {
                Cleaning clining = new Cleaning
                {
                    IdRoom    = rez.IdRoom,
                    CleanTime = date.Date,
                    IdWorker  = -1
                };
                CleaningController.Add(clining);
            }

            if (clinings.Any(p => p.CleanTime.Date == rez.StopTime.Date))
            {
                Cleaning cliningToDelete = clinings.First(p => p.CleanTime.Date == rez.StopTime.Date);
                CleaningController.Delete(cliningToDelete);
            }

            Cleaning lastClining = new Cleaning
            {
                IdRoom    = rez.IdRoom,
                CleanTime = rez.StopTime.Date,
                IdWorker  = -1
            };

            CleaningController.Add(lastClining, true);
        }
        private void EditClining(Reservation rezBeforeChange, Reservation rezAfterChange, SqliteContext conn)
        {
            var cleanings    = conn.Cleanings.Where(r => r.IdRoom == rezAfterChange.IdRoom).ToList();
            var reservations = conn.Reservations.Where(p => p.IdRoom == rezAfterChange.IdRoom).ToList();

            if (rezBeforeChange.StartTime.Date < rezAfterChange.StartTime.Date)
            {
                DateTime dateStart = rezBeforeChange.StartTime.Date;

                if (reservations.Any(p => p.StopTime.Date == rezBeforeChange.StartTime.Date))
                {
                    dateStart = dateStart.AddDays(1);
                }

                for (DateTime date = dateStart; date < rezAfterChange.StartTime.Date; date = date.AddDays(1))
                {
                    var cleaningsForDay = cleanings.Where(t => t.CleanTime.Date == date.Date);
                    foreach (var cleaning in cleaningsForDay)
                    {
                        conn.Cleanings.Remove(cleaning);
                    }
                }
                conn.SaveChanges();
            }
            if (rezBeforeChange.StartTime.Date > rezAfterChange.StartTime.Date)
            {
                DateTime dateStart = rezAfterChange.StartTime.Date;
                if (reservations.Any(p => p.StopTime.Date == rezAfterChange.StartTime.Date))
                {
                    dateStart = dateStart.AddDays(1);
                }

                for (DateTime date = dateStart; date < rezBeforeChange.StartTime.Date; date = date.AddDays(1))
                {
                    Cleaning clining = new Cleaning
                    {
                        IdRoom    = rezAfterChange.IdRoom,
                        CleanTime = date.Date,
                        IdWorker  = -1
                    };
                    CleaningController.Add(clining);
                }
            }
            if (rezAfterChange.StopTime.Date < rezBeforeChange.StopTime.Date)
            {
                bool isReservation = false;
                if (reservations.Any(p => p.StartTime.Date == rezBeforeChange.StopTime.Date))
                {
                    isReservation = true;
                }

                for (DateTime date = rezAfterChange.StopTime.Date; date <= rezBeforeChange.StopTime.Date; date = date.AddDays(1))
                {
                    var cleaningsForDay = cleanings.Where(t => t.CleanTime.Date == date.Date);

                    if (isReservation && date == rezBeforeChange.StopTime.Date && cleaningsForDay.Count() == 2)
                    {
                        conn.Cleanings.Remove(cleaningsForDay.First());
                    }
                    else
                    {
                        foreach (var cleaning in cleaningsForDay)
                        {
                            conn.Cleanings.Remove(cleaning);
                        }
                    }
                }
                conn.SaveChanges();

                Cleaning endingClining = new Cleaning
                {
                    IdRoom    = rezAfterChange.IdRoom,
                    CleanTime = rezAfterChange.StopTime.Date,
                    IdWorker  = -1
                };
                CleaningController.Add(endingClining, true);
            }
            if (rezAfterChange.StopTime.Date > rezBeforeChange.StopTime.Date)
            {
                var cleaningsForDay = cleanings.Where(t => t.CleanTime.Date == rezBeforeChange.StopTime.Date).OrderBy(t => t.CleanTime).LastOrDefault();
                if (cleaningsForDay != null)
                {
                    conn.Cleanings.Remove(cleaningsForDay);
                    conn.SaveChanges();
                }

                if (cleanings.Any(p => p.CleanTime.Date == rezAfterChange.StopTime.Date))
                {
                    Cleaning clean = cleanings.First(p => p.CleanTime.Date == rezAfterChange.StopTime.Date);
                    conn.Cleanings.Remove(clean);
                    conn.SaveChanges();
                }

                for (DateTime date = rezBeforeChange.StopTime.Date.AddDays(1); date < rezAfterChange.StopTime.Date; date = date.AddDays(1))
                {
                    Cleaning clining = new Cleaning
                    {
                        IdRoom    = rezAfterChange.IdRoom,
                        CleanTime = date.Date,
                        IdWorker  = -1
                    };
                    CleaningController.Add(clining);
                }
                Cleaning endingClining = new Cleaning
                {
                    IdRoom    = rezAfterChange.IdRoom,
                    CleanTime = rezAfterChange.StopTime.Date,
                    IdWorker  = -1
                };
                CleaningController.Add(endingClining, true);
            }
        }