public OperationDetails CreateSkinRarity(SkinRarityDTO item, string oldSkinRarity) { if (item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } SkinRarity skinRarity = Database.SkinRareties.Find(x => x.RarityName == oldSkinRarity).FirstOrDefault(); List <Color> colors = new List <Color>(); foreach (var c in item.Colors) { Color color = Database.Colors.Find(cl => cl.Name == c.Name).FirstOrDefault(); if (color != null) { colors.Add(color); } } if (skinRarity != null) { skinRarity.Colors = colors; skinRarity.RarityName = item.RarityName; Database.SkinRareties.Update(skinRarity); Database.Save(); return(new OperationDetails(true, "Раритетность скина была успешно изменена", this.ToString())); } else { skinRarity = _mappers.ToSkinRarity.Map <SkinRarityDTO, SkinRarity>(item); skinRarity.Colors = colors; Database.SkinRareties.Add(skinRarity); Database.Save(); return(new OperationDetails(true, "Раритетность скина была успешно добавлена", this.ToString())); } }
public OperationDetails CreateSkin(SkinDTO item) { if (item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Skin _skin = _mappers.ToSkin.Map <SkinDTO, Skin>(item); if (_skin == null) { return(new OperationDetails(false, "Не удалось преобразовать объект", this.ToString())); } Game _game = Database.Games.Find(x => x.Name == item.Game.Name)?.FirstOrDefault(); if (_game == null) { return(new OperationDetails(false, "Не удалось найти игру с таким названием", this.ToString())); } _skin.Game = _game; SkinRarity _skinRarity = Database.SkinRareties.Find(x => x.RarityName == item.SkinRarity.RarityName)?.FirstOrDefault(); if (_skinRarity == null) { _skinRarity = new SkinRarity { RarityName = item.SkinRarity.RarityName }; } _skin.SkinRarity = _skinRarity; SkinType _skinType = Database.SkinTypes.Find(x => x.TypeName == item.SkinType.TypeName)?.FirstOrDefault(); if (_skinType == null) { _skinType = new SkinType { TypeName = item.SkinType.TypeName }; } foreach (var i in item.Images) { if (i != null) { Image image = Database.Images.Find(x => x.Photo == i.Photo)?.FirstOrDefault(); if (image == null) { image = new Image() { Photo = i.Photo, Text = i.Text }; } _skin.Images.Add(image); } } _skin.SkinType = _skinType; Database.Skins.Add(_skin); Database.Save(); return(new OperationDetails(true, "Скин успешно создан", this.ToString())); }
protected override void Seed(Context db) { SkinRarity _rare = new SkinRarity() { Id = 1, RarityName = "Rare", IsDeleted = false, Color = "#ff0000" }; SkinRarity _common = new SkinRarity() { Id = 2, RarityName = "Common", Color = "#00ff00" }; SkinRarity _legendary = new SkinRarity() { Id = 3, RarityName = "Legendary", Color = "#0000ff" }; db.SkinRarities.Add(_rare); db.SkinRarities.Add(_common); db.SkinRarities.Add(_legendary); SkinType _cloth = new SkinType() { Id = 1, TypeName = "Cloth" }; SkinType _gun = new SkinType() { Id = 2, TypeName = "Gun" }; SkinType _assessory = new SkinType() { Id = 2, TypeName = "Accessory" }; db.SkinTypes.Add(_cloth); db.SkinTypes.Add(_gun); db.SkinTypes.Add(_assessory); Game _CS = new Game() { Id = 1, GameURL = "https://store.steampowered.com/app/730/CounterStrike_Global_Offensive/?l=russian", IsThingGame = true, Genre = "Shooter", Name = "Counter-Strike Global Offensive", Type = "Multiplayer" }; Game _Fortnite = new Game() { Id = 2, GameURL = "https://www.epicgames.com/fortnite/ru/home", IsThingGame = false, Genre = "Battle Royal, Survival", Name = "Fortnite", Type = "Multiplayer" }; db.Games.Add(_CS); db.Games.Add(_Fortnite); base.Seed(db); }
public OperationDetails UpdateSkin(ProductDTO product, SkinDTO item, string oldSkinName) { if (product == null || item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Product localProduct = UpdateProduct(product); Database.Products.Update(localProduct); Skin oldSkin = Database.Skins.Find(s => s.Name == oldSkinName).FirstOrDefault(); if (oldSkin == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } if (oldSkin.Game.Name != item.Game.Name) { Game game = Database.Games.Find(x => x.Name == item.Game.Name)?.FirstOrDefault(); if (game == null) { return(new OperationDetails(false, "Не удалось найти игру с таким названием", this.ToString())); } oldSkin.Game = game; } if (oldSkin.SkinRarity.RarityName != item.SkinRarity.RarityName) { SkinRarity skinRarity = Database.SkinRareties.Find(x => x.RarityName == item.SkinRarity.RarityName)?.FirstOrDefault(); if (skinRarity == null) { return(new OperationDetails(false, "Не удалось найти раритетность с таким названием", this.ToString())); } oldSkin.SkinRarity = skinRarity; } oldSkin.Properties = _mappers.ToProperty.Map <IEnumerable <PropertyDTO>, ICollection <Property> >(item.Properties); Database.Skins.Update(oldSkin); Database.Save(); return(new OperationDetails(true, "Скин успешно изменён", this.ToString())); }
protected override void Seed(Context db) { Color red = new Color() { Name = "Крастный", ColorValue = "#fc2403" }; Color blue = new Color() { Name = "Голубой", ColorValue = "#03cefc" }; Color gray = new Color() { Name = "Серый", ColorValue = "#8f8f8f" }; Color gold = new Color() { Name = "Золотой", ColorValue = "#ffee00" }; Color purple = new Color() { Name = "Фиолетовый", ColorValue = "#c4009a" }; db.Colors.Add(red); db.Colors.Add(blue); db.Colors.Add(purple); db.Colors.Add(gray); db.Colors.Add(gold); SkinRarity _rare = new SkinRarity() { Id = 1, RarityName = "Rare", Colors = new List <Color>() { blue } }; SkinRarity _common = new SkinRarity() { Id = 2, RarityName = "Common", Colors = new List <Color>() { gray } }; SkinRarity _legendary = new SkinRarity() { Id = 3, RarityName = "Legendary", Colors = new List <Color>() { gold } }; db.SkinRarities.Add(_rare); db.SkinRarities.Add(_common); db.SkinRarities.Add(_legendary); Game cs = new Game() { IsThingGame = true, Name = "CS GO", SystemRequirements = "Минимальные системные требования: /br" + "Процессор: Intel® Core™ 2 Duo E6600 / AMD Phenom™ X3 8750 " + "Видеокарта: Видеокарта должна иметь объем видеопамяти не меньше 256 Мб " + "Оперативная память: 2 Гб " + "Операционная система: Windows® 7 / Vista / XP " + "Место на диске: 15 ГБ " + "Рекомендуемые системные требования: " + "Официальных рекомендованных системных требований нет.Ниже представлено наше видение требований, достаточных для игры в FHD разрешении на максимальных настройках." + " Процессор: Intel® Core™ i3 " + "Видеокарта: NVIDIA® GeForce® GTX 1050 2 ГБ и любая видеокарта новее с видеопамятью от 1 Гб " + "Оперативная память: 4 Гб " + "Операционная система: Windows 7 / 8 / 10 " + "Место на диске: 15 ГБ" }; db.Games.Add(cs); Product csProduct = new Product() { FromTableId = 1, Name = "CS GO", Price = 200, Sale = 0, Table = Goods.Game }; db.Products.Add(csProduct); Skin ak = new Skin() { Game = cs, SkinRarity = _legendary, Name = "Ak 47" }; Product akProduct = new Product() { FromTableId = 1, Table = Goods.Skin, Name = "Ak 47", Price = 100, Sale = 10 }; db.Products.Add(akProduct); db.Skins.Add(ak); base.Seed(db); }
void NewSkin(string name, MusicStyle music, int styleId, bool isBand = false, int bandQuantity = 0, bool clothChanger = false, SkinRarity rarity = SkinRarity.common) { skins[curId].skinName = name; skins[curId].musicStyle = music; skins[curId].isBand = isBand; skins [curId].bandN = bandQuantity; skins [curId].isClothChanger = clothChanger; skins [curId].id = curId; skins [curId].styleId = styleId; skins [curId].rarity = rarity; curId++; }
public OperationDetails UpdateSkin(SkinDTO item) { if (item == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Skin _oldSkin = Database.Skins.Get(item.Id); if (_oldSkin == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } if (_oldSkin.Game.Name != item.Game.Name) { Game _game = Database.Games.Find(x => x.Name == item.Game.Name)?.FirstOrDefault(); if (_game == null) { return(new OperationDetails(false, "Не удалось найти игру с таким названием", this.ToString())); } _oldSkin.Game = _game; } if (_oldSkin.SkinRarity.RarityName != _oldSkin.SkinRarity.RarityName) { SkinRarity _skinRarity = Database.SkinRareties.Find(x => x.RarityName == item.SkinRarity.RarityName)?.FirstOrDefault(); if (_skinRarity == null) { _skinRarity = new SkinRarity { RarityName = item.SkinRarity.RarityName }; } _oldSkin.SkinRarity = _skinRarity; } if (_oldSkin.SkinType.TypeName != item.SkinType.TypeName) { SkinType _skinType = Database.SkinTypes.Find(x => x.TypeName == item.SkinType.TypeName)?.FirstOrDefault(); if (_skinType == null) { _skinType = new SkinType { TypeName = item.SkinType.TypeName }; } _oldSkin.SkinType = _skinType; } foreach (var i in item.Images) { if (i != null && i.Photo != _oldSkin.Images.FirstOrDefault().Photo) { Image image = Database.Images.Find(x => x.Photo == i.Photo)?.FirstOrDefault(); if (image == null) { image = new Image() { Photo = i.Photo, Text = i.Text }; } _oldSkin.Images.Add(image); } } _oldSkin.Name = item.Name; _oldSkin.Price = item.Price; _oldSkin.Sale = item.Sale; Database.Skins.Update(_oldSkin); Database.Save(); return(new OperationDetails(true, "Скин успешно изменён", this.ToString())); }
protected override void Seed(Context db) { SkinRarity _rare = new SkinRarity() { Id = 1, RarityName = "Rare", IsDeleted = false, Color = "#ff0000" }; SkinRarity _common = new SkinRarity() { Id = 2, RarityName = "Common", Color = "#00ff00" }; SkinRarity _legendary = new SkinRarity() { Id = 3, RarityName = "Legendary", Color = "#0000ff" }; db.SkinRarities.Add(_rare); db.SkinRarities.Add(_common); db.SkinRarities.Add(_legendary); SkinType _cloth = new SkinType() { Id = 1, TypeName = "Cloth" }; SkinType _gun = new SkinType() { Id = 2, TypeName = "Gun" }; SkinType _assessory = new SkinType() { Id = 2, TypeName = "Accessory" }; db.SkinTypes.Add(_cloth); db.SkinTypes.Add(_gun); db.SkinTypes.Add(_assessory); Game _CS = new Game() { Id = 1, GameURL = "https://store.steampowered.com/app/730/CounterStrike_Global_Offensive/?l=russian", IsThingGame = true, Genre = "Shooter", Name = "Counter-Strike Global Offensive", Type = "Multiplayer" }; Game _Fortnite = new Game() { Id = 2, GameURL = "https://www.epicgames.com/fortnite/ru/home", IsThingGame = false, Genre = "Battle Royal, Survival", Name = "Fortnite", Type = "Multiplayer" }; db.Games.Add(_CS); db.Games.Add(_Fortnite); db.Skins.Add(new Skin() { Id = 1, GameId = 1, Game = _CS, Sale = 0, SkinRarity = _rare, SkinRarityId = 1, SkinTypeId = 2, SkinType = _gun, Name = "Kek", Description = "Top of the top", Price = 2187.12 }); db.Skins.Add(new Skin() { Id = 2, GameId = 1, Game = _CS, Sale = 10, SkinRarity = _legendary, SkinRarityId = 3, SkinTypeId = 2, SkinType = _gun, Name = "Cheburek", Description = "50% of users estimated this one like a very beautiful skin in the world", Price = 100.5 }); db.Skins.Add(new Skin() { Id = 3, GameId = 2, Game = _Fortnite, Sale = 0, SkinRarity = _common, SkinRarityId = 2, SkinTypeId = 1, SkinType = _cloth, Name = "Fort", Description = "For those whoa appretiate", Price = 23.60 }); db.Skins.Add(new Skin() { Id = 4, GameId = 1, Game = _CS, Sale = 0, SkinRarity = _rare, SkinRarityId = 1, SkinTypeId = 2, SkinType = _gun, Name = "Kek", Description = "Top of the top", Price = 2187.12 }); db.Skins.Add(new Skin() { Id = 5, GameId = 1, Game = _CS, Sale = 10, SkinRarity = _legendary, SkinRarityId = 3, SkinTypeId = 2, SkinType = _gun, Name = "Cheburek", Description = "50% of users estimated this one like a very beautiful skin in the world", Price = 100.5 }); db.Skins.Add(new Skin() { Id = 6, GameId = 2, Game = _Fortnite, Sale = 0, SkinRarity = _common, SkinRarityId = 2, SkinTypeId = 1, SkinType = _cloth, Name = "Fort", Description = "For those whoa appretiate", Price = 23.60 }); base.Seed(db); }
public OperationDetails CreateSkin(ProductDTO product, SkinDTO item, string oldSkin) { Product productInDB = Database.Products.Find(p => p.Name == oldSkin).FirstOrDefault(); if (productInDB != null) { return(UpdateSkin(product, item, oldSkin)); } if (item == null || product == null) { return(new OperationDetails(false, "ОбЪект ссылается на null", this.ToString())); } Skin skin = _mappers.ToSkin.Map <SkinDTO, Skin>(item); if (skin == null) { return(new OperationDetails(false, "Не удалось преобразовать объект", this.ToString())); } if (skin.SkinRarity != null) { SkinRarity rarity = Database.SkinRareties.Find(r => r.RarityName == skin.SkinRarity.RarityName).FirstOrDefault(); if (rarity == null) { return(new OperationDetails(false, "Не удалось найти раритетность с таким названием", this.ToString())); } skin.SkinRarity = rarity; } if (skin.Game != null) { Game game = Database.Games.Find(g => g.Name == skin.Game.Name).FirstOrDefault(); if (game == null) { return(new OperationDetails(false, "Не удалось найти игру с таким названием", this.ToString())); } skin.Game = game; } skin.Name = product.Name; Database.Skins.Add(skin); Database.Save(); Product localProduct = _mappers.ToProduct.Map <ProductDTO, Product>(product); if (localProduct == null) { return(new OperationDetails(false, "Не удалось преобразовать объект", this.ToString())); } localProduct = CreateProduct(localProduct); localProduct.Table = Goods.Skin; Skin skinInDB = Database.Skins.Find(x => x.Name == localProduct.Name).FirstOrDefault(); if (skinInDB == null) { return(new OperationDetails(false, "Не удалось найти объект", this.ToString())); } localProduct.FromTableId = skinInDB.Id; Database.Products.Add(localProduct); Database.Save(); return(new OperationDetails(true, "Скин был успешно добавлен", this.ToString())); }
public SkinRarityDTO GetSkinRarity(int id) { SkinRarity skinRarity = Database.SkinRareties.Get(id); return(_mappers.ToSkinRarityDTO.Map <SkinRarity, SkinRarityDTO>(skinRarity)); }