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 int SaveAnalisedFit(string listPublicId, FittingAnalyzed fitAnalysed, string userName = null) { EveShoppingContext contexto = new EveShoppingContext(); eshShoppingList lista = null; eshFitting fit = null; using (TransactionScope scope = new TransactionScope()) { fit = MountFittingFromFittingAnalysed(fitAnalysed); RepositorioShoppingLists repo = new RepositorioShoppingLists(contexto); if (!string.IsNullOrEmpty(listPublicId)) { lista = repo.SelectShopingListPorPublicID(listPublicId); eshShoppingListFitting relation = new eshShoppingListFitting(); fit.eshShoppingListFittings.Add(relation); relation.eshShoppingList = lista; relation.units = 1; repo.ShoppingListUpdated(lista.shoppingListID); } if (!string.IsNullOrEmpty(userName)) { UserProfile up = contexto.UserProfiles.Where(u => u.UserName == userName).FirstOrDefault(); if (up == null) { throw new ApplicationException(Messages.err_usuarioNoExiste); } fit.userID = up.UserId; } repo.CrearFitting(fit); scope.Complete(); } return(fit.fittingID); }
public void DeleteFitFromShoppingLIST(int id, int fittingID, EveShoppingContext context) { eshFitting fit = context.eshFittings.Where(f => f.fittingID == fittingID).FirstOrDefault(); eshShoppingListFitting slf = context.eshShoppingListFittings.Where(s => s.shoppingListID == id && s.fittingID == fit.fittingID).FirstOrDefault(); context.eshShoppingListFittings.Remove(slf); if (!fit.userID.HasValue) { context.eshFittings.Remove(fit); } RepositorioShoppingLists repo = new RepositorioShoppingLists(); foreach (var item in fit.eshShoppingListFittings) { repo.ShoppingListUpdated(item.shoppingListID, context); } context.SaveChanges(); }
public EVFitting SetUnitsToFitInShoppingList(string publicID, int fittingID, int units, IImageResolver imageResolver) { EveShoppingContext contexto = new EveShoppingContext(); //guardamos los cambios eshShoppingListFitting slfit = contexto.eshShoppingListFittings.Where(slf => slf.fittingID == fittingID && slf.eshShoppingList.publicID == publicID).FirstOrDefault(); if (slfit == null) { throw new ApplicationException(Messages.err_fittingNoExiste); } if (units < 1) { units = 1; } slfit.units = units; RepositorioShoppingLists repo = new RepositorioShoppingLists(); repo.ShoppingListUpdated(slfit.shoppingListID, contexto); contexto.SaveChanges(); //obtenemos la fitting return(this.SelectFitSummary(publicID, fittingID, imageResolver)); }
public void UseFitInList(string publicID, int fitID) { EveShoppingContext contexto = new EveShoppingContext(); eshShoppingList sl = contexto.eshShoppingLists.Where(s => s.publicID == publicID).FirstOrDefault(); if (sl == null) { throw new ApplicationException(Messages.err_shoppingLisNoExiste); } if (contexto.eshShoppingListFittings.Where(slf => slf.shoppingListID == sl.shoppingListID && slf.fittingID == fitID).Count() > 0) { throw new ApplicationException(Messages.err_fittigAlreadyUsed); } eshShoppingListFitting slft = new eshShoppingListFitting(); slft.shoppingListID = sl.shoppingListID; slft.fittingID = fitID; slft.units = 1; contexto.eshShoppingListFittings.Add(slft); RepositorioShoppingLists repo = new RepositorioShoppingLists(); repo.ShoppingListUpdated(sl.shoppingListID, contexto); contexto.SaveChanges(); }