public void Write(Product product)
 {
     using (PointOfSaleContext context = new PointOfSaleContext())
     {
         context.Products.AddOrUpdate(product);
         context.SaveChanges();
     }
 }
        private IEnumerable <int> GetProductCodes(PointOfSaleContext context)
        {
            IEnumerable <int> productCodes = (from p in context.Products
                                              orderby p.ProductCode ascending
                                              select p.ProductCode);

            return(productCodes);
        }
Exemple #3
0
        public async Task RegisterAsync(PointOfSale pointOfSale, ChangeComposition composition)
        {
            using var context = new PointOfSaleContext(_configuration);
            await context.Transactions.AddAsync(new Transactions
            {
                ValueToPay    = pointOfSale.ValueToPay,
                TotalValue    = pointOfSale.TotalValue,
                Change        = composition.TotalChange,
                ChangeMessage = composition.ResponseMessage
            });

            await context.SaveChangesAsync();
        }
        public void DeleteByProductCode(int productCode)
        {
            using (PointOfSaleContext context = new PointOfSaleContext())
            {
                Product product = (from p in context.Products
                                   where p.ProductCode == productCode
                                   select p).FirstOrDefault();

                if (product != null)
                {
                    context.Products.Remove(product);
                    context.SaveChanges();
                }
            }
        }
        public int GenerateNew()
        {
            using (PointOfSaleContext context = new PointOfSaleContext())
            {
                IEnumerable <int> productCodes = this.GetProductCodes(context);

                if (!productCodes.Any())
                {
                    return(ProductCodeProvider.StartingCode);
                }

                int productCode = this.GetNextProductCode(productCodes);
                return(productCode);
            }
        }
Exemple #6
0
 public ApplicationsController(PointOfSaleContext context)
 {
     _context = context;
 }
Exemple #7
0
 public POSRepository(PointOfSaleContext _db)
 {
     db = _db;
 }