コード例 #1
0
        public void Delete(ModelBookStore.Item objModelItem)
        {
            Item _SelectRoleToDeleteRow = TBSEntities.Items.Where(x => x.id == objModelItem.id).Select(x => x).FirstOrDefault();

            TBSEntities.Items.Remove(_SelectRoleToDeleteRow);
            TBSEntities.SaveChanges();
        }
コード例 #2
0
        public void Add(ModelBookStore.Item objModelItem)
        {
            Item objItem = new Item()
            {
                Name  = objModelItem.Name,
                Price = objModelItem.Price
            };

            TBSEntities.Items.Add(objItem);
            TBSEntities.SaveChanges();
        }
コード例 #3
0
        public void Update(ModelBookStore.Item objModelItem)
        {
            Item _SelectItemrow = TBSEntities.Items.Where(x => x.id == objModelItem.id).Select(x => x).FirstOrDefault();

            if (_SelectItemrow == null)
            {
                Add(objModelItem);
            }

            else
            {
                _SelectItemrow.Name  = objModelItem.Name;
                _SelectItemrow.Price = objModelItem.Price;

                TBSEntities.SaveChanges();
            }
        }
コード例 #4
0
        public List <ModelBookStore.Item> Search(ModelBookStore.Item objModelItem)
        {
            var Rolelist = (from objItems in TBSEntities.Items
                            where objItems.id == objModelItem.id && objItems.Name == objModelItem.Name
                            select new Role {
                id = objItems.id, Name = objItems.Name
            }).ToList();

            ModelBookStore.Item        ModleItemObj;
            List <ModelBookStore.Item> objlist = new List <ModelBookStore.Item>();

            foreach (var item in Rolelist)
            {
                ModleItemObj      = new ModelBookStore.Item();
                ModleItemObj.id   = item.id;
                ModleItemObj.Name = item.Name;
                objlist.Add(ModleItemObj);
            }

            return(objlist);
        }
コード例 #5
0
        public List <ModelBookStore.Item> Load()
        {
            var Itemlist = (from objItems in TBSEntities.Items

                            select objItems).ToList();

            ModelBookStore.Item ModleItemObj;
            //= new ModelBookStore.Role();
            List <ModelBookStore.Item> objlist = new List <ModelBookStore.Item>();

            foreach (var item in Itemlist)
            {
                ModleItemObj       = new ModelBookStore.Item();
                ModleItemObj.id    = item.id;
                ModleItemObj.Name  = item.Name;
                ModleItemObj.Price = Convert.ToDecimal(item.Price);


                objlist.Add(ModleItemObj);
            }

            return(objlist);
        }