public void DeleteSale(Data.Sale sale) { if (!_context.Sales.Local.Any(sal => sal.ID == sale.ID)) { _context.Sales.Attach(sale); } _context.Sales.Remove(sale); _context.SaveChanges(); }
public Data.Sale UpdateSale(Data.Sale sale) { if (!_context.Sales.Local.Any(sal => sal.ID == sale.ID)) { _context.Sales.Attach(sale); } _context.Entry(sale).State = EntityState.Modified; _context.SaveChanges(); return(sale); }
public Data.Sale RemoveSale(Data.Sale sale) { if (!_context.Sales.Local.Any(s => s.ID == sale.ID)) { _context.Sales.Attach(sale); } _context.Sales.Remove(sale); _context.SaveChanges(); return(sale); }
public static Sale DatabaseSaleToServiceSale(Data.Sale sale) { return(new Sale() { Id = sale.id, Date = sale.sale_time, ProductId = sale.product, ProductAmount = sale.product_amount, CustomerId = sale.customer }); }
public void AddSale() { if (SelectedProduct != null) { ObservableCollection <Data.RecipeItem> recipes = new ObservableCollection <Data.RecipeItem>(_iRecipeRepo.GetRecipes() .Where(recipe => recipe.Product.ID.Equals(SelectedProduct.ID))); bool isAddSalePossible = true; for (int i = 0; i < Amount; i++) { isAddSalePossible = true; foreach (Data.RecipeItem recipe in recipes) { Data.Ingredient ingredient = recipe.Ingredient; if (ingredient.Amount < recipe.Amount) { isAddSalePossible = false; ErrorHandler.ThrowError(0, $"{Properties.Resources.ToLittleOf}: {recipe.Ingredient.Name}"); } } if (isAddSalePossible) { foreach (Data.RecipeItem recipe in recipes) { Data.Ingredient ingredient = recipe.Ingredient; ingredient.Amount -= recipe.Amount; _iIngredientRepo.UpdateIngredient(ingredient); } Data.Sale sale = new Data.Sale() { Cooked = 0, Delivered = 0, Paid = 0, Product = SelectedProduct.ConvertToData() }; _iOccupanciesRepo.AddSale(_occupancy, sale); MessageHandler.InvokeSuccessMessage(Properties.Resources.InformationAddSale, Properties.Resources.InformationSaleAdded.Replace("{product}", $"{SelectedProduct.Name}")); } } ViewBack(); } }
public void AddSale(Data.Sale sale) { _DataContext.Sales.Add(Mapper.DatabaseSaleToServiceSale(sale)); }
public Data.Sale AddSale(Data.Table table, Data.Sale sale) { //table.Occupancy.Sales.Add(sale); _context.SaveChanges(); return(sale); }
private void _tableOccupancyViewModel_PaySelectedSaleRequested(Data.Sale sale) { _occupancyRepo.UpdateSale(sale); }
private void _tableOccupancyViewModel_RemoveSaleRequested(Data.Sale sale) { _occupancyRepo.RemoveSale(sale); }
public Data.Sale AddSale(Data.Occupancy occupancy, Data.Sale sale) { occupancy.Sales.Add(sale); _context.SaveChanges(); return(sale); }
public WaiterSale(Data.Sale sale, Data.Occupancy occupancy) { _sale = sale; _occupancy = occupancy; }