Beispiel #1
0
 public IEnumerable <db.ef.Category> Get()
 {
     using (var ctx = new db.ef.MajigContext())
     {
         return(ctx.Category.ToList());
     }
 }
Beispiel #2
0
 public db.ef.Category Get(int id)
 {
     using (var ctx = new db.ef.MajigContext())
     {
         return(ctx.Category.Where(x => x.Id == id).FirstOrDefault());
     }
 }
Beispiel #3
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);
            }
        }
Beispiel #4
0
 public IEnumerable <db.ef.vItems> Get()
 {
     using (var ctx = new db.ef.MajigContext())
     {
         return(ctx.vItems.ToList());
     }
 }
Beispiel #5
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);
     }
 }
Beispiel #6
0
        static void Main(string[] args)
        {
            using (var db = new db.ef.MajigContext())
            {
                var jjj = db.vCategory.ToList();

                foreach (var item in jjj)
                {
                    Console.WriteLine($"{item.Id} - {item.Category1} - {item.Crumb}");
                }
            }
        }
Beispiel #7
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);
                }
            }
        }