public async Task <IActionResult> PutComic(long id, Comic comic) { if (id != comic.ComicId) { return(BadRequest()); } _context.Entry(comic).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ComicExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutVendor(long id, Vendor vendor) { if (id != vendor.VendorId) { return(BadRequest()); } _context.Entry(vendor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VendorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task SaveAll(List <League> leagues) { using var context = new SidekickContext(options); context.Leagues.RemoveRange(await FindAll()); context.AddRange(leagues); await context.SaveChangesAsync(); }
public async Task SaveTranslations(List <NinjaTranslation> translations) { using var dbContext = new SidekickContext(options); translations = translations .GroupBy(x => x.English) .Select(x => x.First()) .ToList(); var names = translations.Select(x => x.English); var data = await dbContext.NinjaTranslations .Where(x => names.Any(y => y == x.English)) .ToListAsync(); dbContext.NinjaTranslations.RemoveRange(data); await dbContext.SaveChangesAsync(); dbContext.NinjaTranslations.AddRange(translations); await dbContext.SaveChangesAsync(); }
public async Task SavePrices(List <NinjaPrice> prices) { using var dbContext = new SidekickContext(options); prices = prices .GroupBy(x => (x.Name, x.Corrupted, x.MapTier, x.GemLevel)) .Select(x => x.OrderBy(x => x.Price).First()) .ToList(); var names = prices.Select(x => x.Name); var data = await dbContext.NinjaPrices .Where(x => names.Any(y => y == x.Name)) .ToListAsync(); dbContext.NinjaPrices.RemoveRange(data); await dbContext.SaveChangesAsync(); dbContext.NinjaPrices.AddRange(prices); await dbContext.SaveChangesAsync(); }
public async Task Delete(string type) { using var dbContext = new SidekickContext(options); var itemCategory = await dbContext.ItemCategories.FindAsync(type); if (itemCategory != null) { dbContext.ItemCategories.Remove(itemCategory); await dbContext.SaveChangesAsync(); } }
public async Task Clear() { using var dbContext = new SidekickContext(options); var prices = await dbContext.NinjaPrices.ToListAsync(); dbContext.NinjaPrices.RemoveRange(prices); var translations = await dbContext.NinjaTranslations.ToListAsync(); dbContext.NinjaTranslations.RemoveRange(translations); await dbContext.SaveChangesAsync(); }
public async Task Delete(string type) { logger.Debug($"ItemCategoryService : Deleting data for {type}"); using var dbContext = new SidekickContext(options); var itemCategory = await dbContext.ItemCategories.FindAsync(type); if (itemCategory != null) { dbContext.ItemCategories.Remove(itemCategory); await dbContext.SaveChangesAsync(); } }
public async Task SaveCategory(string type, string category) { using var dbContext = new SidekickContext(options); var itemCategory = await dbContext.ItemCategories.FindAsync(type); if (itemCategory == null) { itemCategory = new ItemCategory() { Type = type, }; dbContext.ItemCategories.Add(itemCategory); } itemCategory.Category = category; await dbContext.SaveChangesAsync(); }
public async Task SaveSize(View id, int width, int height) { using var context = new SidekickContext(options); var preference = await context.ViewPreferences.FindAsync(id); if (preference == null) { preference = new ViewPreference() { Id = id, }; context.ViewPreferences.Add(preference); } preference.Height = height; preference.Width = width; await context.SaveChangesAsync(); }
public async Task SaveCategory(string type, string category) { logger.Debug($"ItemCategoryService : Saving data for {type}"); using var dbContext = new SidekickContext(options); var itemCategory = await dbContext.ItemCategories.FindAsync(type); if (itemCategory == null) { itemCategory = new ItemCategory() { Type = type, }; dbContext.ItemCategories.Add(itemCategory); } itemCategory.Category = category; await dbContext.SaveChangesAsync(); }
public async Task SaveSize(string id, double width, double height) { using var dbContext = new SidekickContext(options); var window = await dbContext.Windows.FindAsync(id); if (window == null) { window = new Window() { Id = id, }; dbContext.Windows.Add(window); } window.Height = height; window.Width = width; await dbContext.SaveChangesAsync(); logger.Debug($"WindowService : Saved data for {id}. Width: {width}, Height: {height}"); }