public static bool TryGetZayavka(out Zayavka zayavka) { zayavka = null; if (_numberOfCurrentZayavok == 10000) { return(false); } if (_currentValue <= 0) { var randomNumber = Math.Log(1 - Random.NextDouble()) / -1; _currentValue = Convert.ToInt32(randomNumber * 10); while (_currentValue > 10) { _currentValue %= 10; } zayavka = new Zayavka(); return(true); } zayavka = new Zayavka(); _numberOfCurrentZayavok++; _currentValue--; return(true); }
public bool TryToAddZayavka(Zayavka zayavka) { if (Zayavki.Count >= CountOfMaximumZayavok) { return(false); } Zayavki.Enqueue(zayavka); return(true); }
public bool TryMaintainNewZayavka(Zayavka zayavka) { if (zayavka == null) { return(false); } var obrabotchikToAddZayavka = Obrabotchiks.FirstOrDefault(obrabotchik => obrabotchik.Zayavka == null); if (obrabotchikToAddZayavka == null) { return(Nakopitel.TryToAddZayavka(zayavka)); } obrabotchikToAddZayavka.Zayavka = zayavka; return(true); }