/// <summary> /// Locks seats /// </summary> private void LockSeats(Spot[] spots) { List <Seat> seats = new List <Seat>(); foreach (Spot spot in spots) { Seat seat = new Seat(); seat.Id = spot.Id; seat.ReserveDate = ReserveDate; seats.Add(seat); } List <Seat> lockedSeats = Data.Access.LockSeats(seats); if (lockedSeats != null) { HashSet <int> writerIds = new HashSet <int>(lockedSeats.Select(x => x.Id)); seats.RemoveAll(x => writerIds.Contains(x.Id)); foreach (Seat s in seats) { SelectedSpots.Remove(SelectedSpots.Single(i => i.Id == s.Id)); Spots.Remove(Spots.Single(i => i.Id == s.Id)); } int counter = 0; decimal price = 0; foreach (Spot spot in SelectedSpots) { counter++; price += spot.Price; spot.ItemId = counter; } StatusText = String.Format("Удерживается {0} мест на сумму {1}", SeatsCount.ToString("### ##0"), SeatsAmount.ToString("C0")); OperationResult = String.Format("Выбрано мест {0} на сумму {1}", counter, price.ToString("C")); } }