Beispiel #1
0
 public List <byte[]> GetItemsImages(int?id)
 {
     using (var db = new LoetopiaContext())
     {
         return(db.ItemImages.Where(x => id == null || x.ItemImageId == id).Select(x => x.Image).ToList());
     }
 }
Beispiel #2
0
 public List <DataAccess.Attribute> GetAttributes(int?id)
 {
     using (var db = new LoetopiaContext())
     {
         return(db.Attributes
                .Where(x => id == null || x.AttributeId == id)
                .ToList());
     }
 }
Beispiel #3
0
 public List <ItemsAttributes> GetItemsAttributes(int?id)
 {
     using (var db = new LoetopiaContext())
     {
         return(db.ItemAttributes.Where(x => id == null || x.ItemId == id).Select(x =>
                                                                                  new ItemsAttributes {
             Name = x.Attribute.Name, Description = x.Attribute.Description, Value = x.Value
         })
                .ToList());
     }
 }
Beispiel #4
0
        public async Task <int> AddItem(Item item)
        {
            using (var db = new LoetopiaContext())
            {
                db.Items.Add(item);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(item.ItemId);
                }

                return(0);
            }
        }
Beispiel #5
0
 public List <ItemDescription> GetItemInformation(int?id)
 {
     using (var db = new LoetopiaContext())
     {
         return(db.Items
                .Where(x => id == null || x.ItemId == id)
                .Select(x =>
                        new ItemDescription {
             ItemId = x.ItemId, Name = x.Name, Description = x.Description, Type = x.ItemType.Name, TypeDescription = x.ItemType.Description, Durability = x.Durability, RequiredLevel = x.RequiredLevel
         })
                .ToList());
     }
 }
Beispiel #6
0
        public async Task <bool> AddAttribute(DataAccess.Attribute attribute)
        {
            using (var db = new LoetopiaContext())
            {
                db.Attributes.Add(attribute);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
Beispiel #7
0
        public async Task <bool> AddItemAttribute(ItemAttribute itemAttribute)
        {
            using (var db = new LoetopiaContext())
            {
                db.ItemAttributes.Add(itemAttribute);
                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
Beispiel #8
0
        public async Task <bool> AddItemImages(int id, byte[] image)
        {
            using (var db = new LoetopiaContext())
            {
                db.ItemImages.Add(new ItemImage()
                {
                    ItemId = id, Image = image
                });
                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
Beispiel #9
0
        public async Task <bool> RemoveItem(int id)
        {
            using (var db = new LoetopiaContext())
            {
                var entity = db.Items.Where(x => x.ItemId == id).FirstOrDefault();
                entity.Active = false;

                db.Entry(entity).State = EntityState.Modified;

                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }
Beispiel #10
0
        public async Task <bool> UpdateItem(int id, Item item)
        {
            using (var db = new LoetopiaContext())
            {
                if (id != item.ItemId)
                {
                    return(false);
                }

                db.Entry(item).State = EntityState.Modified;

                if (await db.SaveChangesAsync() > 0)
                {
                    return(true);
                }

                return(false);
            }
        }