Esempio n. 1
0
        public AllGoods Update(IDataProvider dBConect, AllGoods goods, RozetkaGoods realGoods)
        {
            if (goods == null || realGoods == null || dBConect == null)
            {
                return(null);
            }

            string realPrise = (realGoods.Price.Value).Replace(" ", string.Empty);
            double prise;

            if (!double.TryParse(realPrise, out prise))
            {
                return(null);
            }

            if (goods.Price != prise)
            {
                double oldValue = goods.Price;
                goods.Price = prise;
                ChangeDynamics changeDynamics = new ChangeDynamics();
                changeDynamics.NewPrice   = prise;
                changeDynamics.OldPrice   = oldValue;
                changeDynamics.UpdateTime = DateTime.Now;
                changeDynamics.AllGoodsId = goods.Id;
                dBConect.AddChangeDynamics(changeDynamics);
                dBConect.SaveChanges();
            }
            return(goods);
        }