public long Add(WeatherReport report) { lock (_lock) { report.Id = _reports.Count + 1; _reports.Add(report); return(report.Id); } }
public virtual long SendReport(WeatherReport report) { Console.WriteLine("SendReport for " + report.Location + ": request"); long id = _reportRepository.Add(report); Thread.Sleep(TimeSpan.FromMilliseconds(_random.Next(100, 1000))); Console.WriteLine("SendReport for " + report.Location + ": returning Report ID = " + id); return(id); }
public long Add(WeatherReport report) { lock (_lock) { report.Id = _reports.Count + 1; _reports.Add(report); if (report.Id % 5 == 0) { Console.WriteLine("Throwing exception for Report ID = " + report.Id); throw new InvalidOperationException($"Oops! Report with ID '{report.Id}' produced an error on server. Look for its Fault_Response.xml in log folder."); } return(report.Id); } }