public eshShoppingListInvType UpdateMarketItemEnShoppingList(int listID, int itemID, int units) { eshShoppingListInvType slit = SelectMarketItemEnShoppingListPorID(listID, itemID); if (slit == null) { CreateMarketItemEnShoppingList(listID, itemID, units); } else { invType it = Contexto.invTypes.Where(it2 => it2.typeID == itemID).FirstOrDefault(); if (it == null) { throw new ApplicationException(Messages.err_itemNoExiste); } slit.units = units; if (slit.units < 0) { slit.units = 0; } RepositorioItems repoItems = new RepositorioItems(this.Contexto); slit.volume = slit.units * RepositorioItems.GetVolume(it); } Contexto.SaveChanges(); return(slit); }
internal void DeleteItemFromShoppingList(int id, int itemID, EveShoppingContext contexto = null) { RepositorioShoppingLists repo = new RepositorioShoppingLists(contexto); eshShoppingListInvType item = repo.SelectMarketItemEnShoppingListPorID(id, itemID); contexto.eshShoppingListInvTypes.Remove(item); repo.ShoppingListUpdated(id, contexto); contexto.SaveChanges(); }
public void UpdateMarketItemToShoppingList(string publicID, int itemID, int units) { RepositorioShoppingLists repo = new RepositorioShoppingLists(); eshShoppingList list = repo.SelectShopingListPorPublicID(publicID); if (units < 1) { units = 1; } eshShoppingListInvType slit = repo.UpdateMarketItemEnShoppingList(list.shoppingListID, itemID, units); repo.ShoppingListUpdated(list.shoppingListID); }
public eshShoppingListInvType CreateMarketItemEnShoppingList(int listID, int itemID, int units) { eshShoppingListInvType slit = new eshShoppingListInvType(); slit.typeID = itemID; slit.shoppingListID = listID; slit.units = units; invType it = Contexto.invTypes.Where(it2 => it2.typeID == itemID).FirstOrDefault(); if (it == null) { throw new ApplicationException(Messages.err_itemNoExiste); } RepositorioItems repoItems = new RepositorioItems(); slit.volume = units * RepositorioItems.GetVolume(it); Contexto.eshShoppingListInvTypes.Add(slit); Contexto.SaveChanges(); return(slit); }