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); }
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); }