public void AddTag(int itemId, string newTag)
        {
            ItemEntity item = db.Set <ItemEntity>().ToList().First(x => x.ItemId == itemId);

            if (item == null)
            {
                return;
            }
            bool exists = false;

            foreach (TagEntity t in item.Tags) //check each tag if it exists
            {
                if (t.Type == newTag)
                {
                    exists = true;
                }
            }
            if (!exists) //if it doesnt exist add it
            {
                item.Tags.Add(new TagEntity()
                {
                    Type = newTag,
                });
            }
        }
示例#2
0
        public void AddImage(int itemId, string image)
        {
            ItemEntity item = db.Set <ItemEntity>().First(x => x.ItemId == itemId);

            item.Images.Add(new ImageEntity
            {
                ImageOfItem = image
            });
        }
示例#3
0
        public void AddBid(int itemId, int bid, int userId)
        {
            ItemEntity item = db.Set <ItemEntity>().Find(itemId);

            if (item != null)
            {
                foreach (BidEntity b in item.Bids)
                {
                    if (b.Bid >= bid)
                    {
                        return;
                    }
                }
                item.Bids.Add(new BidEntity
                {
                    Bid         = bid,
                    UserIdBuyer = userId
                });
            }
        }