Exemple #1
0
        public db.ef.Item Update(db.ef.Item item)
        {
            using (var ctx = new db.ef.MajigContext())
            {
                var thisItem = ctx.Item.Where(x => x.Id == item.Id).FirstOrDefault();

                if (thisItem != null)
                {
                    thisItem.Id             = item.Id;
                    thisItem.Active         = item.Active;
                    thisItem.UniqueId       = item.UniqueId;
                    thisItem.ParentId       = item.ParentId;
                    thisItem.CategoryId     = item.CategoryId;
                    thisItem.CreateDate     = DateTime.Now;
                    thisItem.ConfigHeaderId = item.ConfigHeaderId;
                    thisItem.BrandId        = item.BrandId;
                    thisItem.ItemName       = item.ItemName;
                    thisItem.ItemDesc       = item.ItemDesc;
                    thisItem.Url            = item.Url;
                    thisItem.Price          = item.Price;
                    ctx.SaveChanges();
                }

                return(thisItem);
            }
        }
Exemple #2
0
 public db.ef.Item Create(db.ef.Item item)
 {
     using (var ctx = new db.ef.MajigContext())
     {
         ctx.Item.Add(item);
         ctx.SaveChanges();
         return(item);
     }
 }
Exemple #3
0
        public int Delete(db.ef.Item item)
        {
            using (var ctx = new db.ef.MajigContext())
            {
                var thisItem = ctx.Item.Where(x => x.Id == item.Id).FirstOrDefault();

                if (thisItem != null)
                {
                    ctx.Item.Remove(thisItem);
                    return(ctx.SaveChanges());
                }
                else
                {
                    return(0);
                }
            }
        }