public bool Insert(RouterModel router) { int retries = 3; while (retries > 0) { try { return(mongo.InsertRecord <RouterModel>("router", router)); } catch (Exception e) { retries--; Thread.Sleep(1000); } } Console.WriteLine("Error to insert document"); return(false); }