Exemplo n.º 1
0
 public static BakeshopProductDomain ToDomain(this BakeshopProduct bakeshopProduct)
 {
     return(new BakeshopProductDomain
     {
         ExpirationDate = bakeshopProduct.ExpirationDate,
         ReceivedDate = bakeshopProduct.ReceivedDate,
         Quantity = bakeshopProduct.Quantity,
         Name = bakeshopProduct.Name,
         IsExpired = bakeshopProduct.ExpirationDate > DateTime.UtcNow ? true : false,
         UomType = bakeshopProduct.UomType,
         Id = bakeshopProduct.Id
     });
 }
Exemplo n.º 2
0
        public void OrderProducts()
        {
            if (string.IsNullOrEmpty(SelectedProductType) || string.IsNullOrEmpty(SelectedUom) || string.IsNullOrEmpty(Quantity))
            {
                MessageBox.Show("If you want to order something need to enter correct data", "Information", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            var bakeshopProduct = new BakeshopProduct
            {
                Name           = SelectedProductType,
                Quantity       = int.Parse(Quantity),
                ReceivedDate   = DateTime.UtcNow,
                SupplierId     = Supplier.Id,
                UomType        = ConverStringUomToEnum(SelectedUom),
                ExpirationDate = DateTime.UtcNow.AddDays(3)
            };

            _context.BakeshopProducts.Add(bakeshopProduct);
            _context.SaveChanges();

            MessageBox.Show("Succesfully ordered", "Information", MessageBoxButton.OK, MessageBoxImage.Warning);
            CloseAction();
        }