public void Test_CheckNameShopeInDb(string nameShope, bool expected)
 {
     try
     {
         dAOEntity_ = new DAOEntity_Framfork();
         bool resulte = dAOEntity_.CheckNameShopeInDb(nameShope);
         NUnit.Framework.Assert.AreEqual(expected, resulte);
     }
     catch (ArgumentNullException) { }
     catch (Exception)
     {
         Assert.Fail();
     }
 }
Exemplo n.º 2
0
        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);
                }
            }
        }