Exemplo n.º 1
0
        public ActionResult Edit(ProductSold prods)
        {
            using (var db = new Onboard1DbContext())
            {
                if (ModelState.IsValid)
                {
                    var sale = db.ProductSolds.FirstOrDefault(x => x.Id == prods.Id);
                    if (sale != null)
                    {
                        sale.ProductId  = prods.ProductId;
                        sale.CustomerId = prods.CustomerId;
                        sale.StoreId    = prods.StoreId;
                        sale.DateSold   = prods.DateSold;
                    }

                    db.SaveChanges();
                    return(RedirectToAction("GetSalesList"));
                }


                ViewBag.ProductId  = db.Products.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.CustomerId = db.Customers.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.StoreId    = db.Stores.Select(x => new { x.Id, x.Name }).ToList();
                return(View(prods));
            }
        }
        public ActionResult DeleteConfirm(int id)
        {
            using (var db = new Onboard1DbContext())
            {
                var stor     = db.Stores.FirstOrDefault(x => x.Id == id);
                var prodsold = db.ProductSolds.FirstOrDefault(x => x.Id == id);
                var storeid  = db.ProductSolds.FirstOrDefault(x => x.StoreId == id);

                if (stor != null)
                {
                    db.Stores.Remove(stor);
                }
                if (prodsold != null)
                {
                    db.ProductSolds.Remove(prodsold);
                }
                if (storeid != null)
                {
                    db.ProductSolds.Remove(storeid);
                }

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
 public ActionResult Delete(int id)
 {
     using (var db = new Onboard1DbContext())
     {
         var custom = db.Customers.FirstOrDefault(x => x.Id == id);
         return(View(custom));
     }
 }
 // DELETE
 public ActionResult Delete(int id)
 {
     using (var db = new Onboard1DbContext())
     {
         var stor = db.Stores.FirstOrDefault(x => x.Id == id);
         return(View(stor));
     }
 }
Exemplo n.º 5
0
 // DELETE
 public ActionResult Delete(int id)
 {
     using (var db = new Onboard1DbContext())
     {
         var prod = db.Products.FirstOrDefault(x => x.Id == id);
         return(View(prod));
     }
 }
Exemplo n.º 6
0
        // CREATE NEW PRODUCT SOLD/SALES
        public ActionResult Create()
        {
            using (var db = new Onboard1DbContext())
            {
                ViewBag.ProductId  = db.Products.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.CustomerId = db.Customers.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.StoreId    = db.Stores.Select(x => new { x.Id, x.Name }).ToList();

                return(View());
            }
        }
Exemplo n.º 7
0
        public ActionResult Edit(int Id)
        {
            using (var db = new Onboard1DbContext())
            {
                var sale = db.ProductSolds.FirstOrDefault(x => x.Id == Id);

                ViewBag.ProductId  = db.Products.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.CustomerId = db.Customers.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.StoreId    = db.Stores.Select(x => new { x.Id, x.Name }).ToList();

                return(View(sale));
            }
        }
 public ActionResult DeleteConfirm(int id)
 {
     using (var db = new Onboard1DbContext())
     {
         var custom = db.Customers.FirstOrDefault(x => x.Id == id);
         if (custom != null)
         {
             db.Customers.Remove(custom);
         }
         db.SaveChanges();
         return(RedirectToAction("GetCustomerList"));
     }
 }
        public ActionResult Edit(Store stor)
        {
            using (var db = new Onboard1DbContext())
            {
                var stori = db.Stores.FirstOrDefault(x => x.Id == stor.Id);
                stori.Id      = stor.Id;
                stori.Name    = stor.Name;
                stori.Address = stor.Address;
                db.SaveChanges();
                return(RedirectToAction("Index"));

                //return View(prod);
            }
        }
        public ActionResult Create(Customer cust)
        {
            if (ModelState.IsValid)
            {
                using (var db = new Onboard1DbContext())
                {
                    db.Customers.Add(cust);
                    db.SaveChanges();
                    return(RedirectToAction("GetCustomerList"));
                }
            }

            return(View());
        }
Exemplo n.º 11
0
        public ActionResult DeleteConfirmed(int id)
        {
            using (var db = new Onboard1DbContext())
            {
                var productsold = db.ProductSolds.FirstOrDefault(x => x.Id == id);
                if (productsold != null)
                {
                    db.ProductSolds.Remove(productsold);
                }

                db.SaveChanges();
                return(RedirectToAction("GetSalesList"));
            }
        }
        // GET: Store list
        public ActionResult Index()
        {
            using (var db = new Onboard1DbContext())
            {
                var store = db.Stores.Select(x => new MyStore
                {
                    Id      = x.Id,
                    Name    = x.Name,
                    Address = x.Address
                }).ToList();

                return(View(store));
            }
        }
Exemplo n.º 13
0
        public ActionResult Create(Product prod)
        {
            if (ModelState.IsValid)
            {
                using (var db = new Onboard1DbContext())
                {
                    db.Products.Add(prod);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }

            return(View());
        }
Exemplo n.º 14
0
        public ActionResult Edit(Product prod)
        {
            using (var db = new Onboard1DbContext())
            {
                var producti = db.Products.FirstOrDefault(x => x.Id == prod.Id);
                producti.Id    = prod.Id;
                producti.Name  = prod.Name;
                producti.Price = prod.Price;
                db.SaveChanges();
                return(RedirectToAction("Index"));

                //return View(prod);
            }
        }
Exemplo n.º 15
0
        // GET: Product
        public ActionResult Index()
        {
            using (var db = new Onboard1DbContext())
            {
                var product = db.Products.Select(x => new MyProduct
                {
                    Id    = x.Id,
                    Name  = x.Name,
                    Price = x.Price
                }).ToList();

                return(View(product));
            }
        }
Exemplo n.º 16
0
 public ActionResult Delete(int id)
 {
     using (var db = new Onboard1DbContext())
     {
         var sold = db.ProductSolds.Where(x => x.Id == id).Select(x => new MyProductSold
         {
             Id           = x.Id,
             ProductName  = x.Product.Name,
             CustomerName = x.Customer.Name,
             StoreName    = x.Store.Name,
             DateSold     = x.DateSold
         }).FirstOrDefault();
         return(View(sold));
     }
 }
        // GET: Customer
        public ActionResult GetCustomerList()
        {
            List <MyCustomer> custom;

            using (var db = new Onboard1DbContext())
            {
                custom = db.Customers.Select(x => new MyCustomer
                {
                    Id      = x.Id,
                    Name    = x.Name,
                    Address = x.Address
                }).ToList();
            }

            return(View(custom));
        }
        public ActionResult Edit(Customer cust)
        {
            using (var db = new Onboard1DbContext())
            {
                var custom = db.Customers.FirstOrDefault(x => x.Id == cust.Id);
                if (custom != null)
                {
                    custom.Id      = cust.Id;
                    custom.Name    = cust.Name;
                    custom.Address = cust.Address;
                }

                db.SaveChanges();
                return(RedirectToAction("GetCustomerList"));
            }
        }
Exemplo n.º 19
0
        public ActionResult Create(ProductSold prods)
        {
            using (var db = new Onboard1DbContext())
            {
                if (ModelState.IsValid)
                {
                    db.ProductSolds.Add(prods);
                    db.SaveChanges();
                    return(RedirectToAction("GetSalesList"));
                }

                ViewBag.ProductId  = db.Products.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.CustomerId = db.Customers.Select(x => new { x.Id, x.Name }).ToList();
                ViewBag.StoreId    = db.Stores.Select(x => new { x.Id, x.Name }).ToList();
                return(View(prods));
            }
        }
Exemplo n.º 20
0
        // GET: Sales
        public ActionResult GetSalesList()
        {
            List <MySale> sale;

            using (var db = new Onboard1DbContext())
            {
                sale = db.ProductSolds.Select(x => new MySale
                {
                    Id           = x.Id,
                    ProductName  = x.Product.Name,
                    CustomerName = x.Customer.Name,
                    StoreName    = x.Store.Name,
                    DateSold     = x.DateSold
                }).ToList();
            }
            return(View(sale));
        }