public async Task GetAllProduct(string nameShope) { bool isShopeDB = default; isShopeDB = _dAOEntity_Framfork.CheckNameShopeInDb(nameShope); shope = GetShope(nameShope); workerParser = new WorkerParser(shope); if (isShopeDB) { bool isCurentDay = _dAOEntity_Framfork.CheckInDbOnDate(nameShope, DateTime.Today.ToLongDateString()); var listXz = _dAOEntity_Framfork.GetAllProduct(nameShope, isCurentDay); if (listXz != null) { try { workerParser.UpdateProduct(listXz); await Task.Run(() => { _dAOEntity_Framfork.UpdateProduct(nameShope); }); } catch (HttpRequestException) { _dAOEntity_Framfork.GetAllProduct(nameShope, true); } catch (Exception e) { throw new Exception(e.Message); } } } else { try { workerParser.GetProducts(); await Task.Run(async() => { await _dAOEntity_Framfork.AddAllProductInDB(nameShope); }); } catch (Exception e) { throw new Exception(e.Message); } } }
public void Test_CheckInDbOnDate(string nameShope, string day, bool expected) { string dataTime = null; try { dAOEntity_ = new DAOEntity_Framfork(); if (day == "ToDay") { dataTime = DateTime.Today.ToLongDateString(); } else if (day == "ToMorrow") { dataTime = DateTime.Today.AddDays(1).ToLongDateString(); } bool resulte = dAOEntity_.CheckInDbOnDate(nameShope, dataTime); NUnit.Framework.Assert.AreEqual(expected, resulte); } catch (ArgumentNullException) { } catch (Exception) { Assert.Fail(); } }