Exemplo n.º 1
0
        public ActionResult Create(Product product)
        {
            try
            {

                service.Save(product);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var service = new ProductService(new ProductEFRepository());
            Console.WriteLine(service.GenerateCode());

            //var product = service.New();

            var product = new Product { Id = 1, Code = "P01", Name = "Test" };
            var product1 = new Product { Id = 1, Code = "P01", Name = "Test" };

            Console.WriteLine(product == product1);
            Console.WriteLine(product.Equals(product1));
            Console.WriteLine(product.GetHashCode());
            Console.WriteLine(product1.GetHashCode());
        }
Exemplo n.º 3
0
 public ActionResult Edit(Product product)
 {
     try
     {
         // TODO: Add update logic here
         service.Save(product);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
Exemplo n.º 4
0
 //
 // GET: /Product/Create
 public ActionResult Create()
 {
     var count = service.GetCount();
     var product = new Product { Id = count, Code = "P" + (count + 1) };
     return View(product);
 }
Exemplo n.º 5
0
 public SaleLineItem(Product product, int quantity)
 {
     this.Product = product;
     this.Quantity = quantity;
 }
Exemplo n.º 6
0
 public void AddProductItem(Product product)
 {
     Items.Add(product);
 }
Exemplo n.º 7
0
 public void AddLineItem(Product product, int quantity = 1)
 {
     var sli = new SaleLineItem(product, quantity);
     LineItems.Add(sli);
 }