Exemplo n.º 1
0
 private void Good_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     if (AddOrDelete == 2)
     {
         DAL.Good g = unitOfWork.Good.GetAll().FirstOrDefault(x => x.Id == ((Good)e.OldItems[0]).GoodId);
         unitOfWork.Good.Remove(g);
     }
     else if (AddOrDelete == 1)
     {
         if (e.NewItems[0] != null)
         {
             string   name      = ((Good)e.NewItems[0]).GoodName;
             int      catId     = ((Good)e.NewItems[0]).CategoryId;
             string   image     = ((Good)e.NewItems[0]).Image;
             string   descr     = ((Good)e.NewItems[0]).Description;
             string   fullDescr = ((Good)e.NewItems[0]).DescriptionFull;
             double   price     = ((Good)e.NewItems[0]).Price;
             DAL.Good g         = new DAL.Good
             {
                 CategoryId      = catId,
                 Name            = name,
                 Description     = descr,
                 DescriptionFull = fullDescr,
                 ImagePath       = image,
                 Price           = price
             };
             unitOfWork.Good.CreateOrUpdate(g);
         }
     }
     unitOfWork.SaveChanges();
 }
Exemplo n.º 2
0
        public void ShopAdo_PropertyChangedGood(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            Good g = sender as Good;

            DAL.Good dg = unitOfWork.Good.Get(g.GoodId);
            dg.CategoryId      = g.CategoryId;
            dg.Name            = g.GoodName;
            dg.Price           = g.Price;
            dg.ImagePath       = g.Image;
            dg.Description     = g.Description;
            dg.DescriptionFull = g.DescriptionFull;

            unitOfWork.Good.CreateOrUpdate(dg);
        }
Exemplo n.º 3
0
 public void AddGoods(Good goods)
 {
     db.Goods.Add(goods);
     db.SaveChanges();
 }
Exemplo n.º 4
0
 public void Remove(Good g)
 {
     db.Entry(g).State = EntityState.Deleted;
 }
Exemplo n.º 5
0
 public void CreateOrUpdate(Good g)
 {
     db.Goods.AddOrUpdate(g);
 }