Exemple #1
0
        public ActionResult Index(string Sort)
        {
            using (var db = new DemoFPTEntities())
            {
                var list = db.Products.ToList();
                //ViewBag.Id = Sort == "id_decs" ? "id" : "id_decs";
                if (Sort == "id_desc")
                {
                    ViewBag.Id = "id";
                }
                else
                {
                    ViewBag.Id = "id_desc";
                }
                switch (Sort)
                {
                case "id_desc":
                    list = list.OrderByDescending(x => x.Id).ToList();
                    break;

                case "id":
                    list = list.OrderBy(x => x.Id).ToList();
                    break;

                default:
                    list = list.OrderBy(x => x.Id).ToList();
                    break;
                }
                return(View(list));
            }
        }
Exemple #2
0
 public ActionResult Delete(int id)
 {
     using (var db = new DemoFPTEntities())
     {
         db.sp_Delete_Product(id);
         return(RedirectToAction("Index"));
     }
 }
Exemple #3
0
 // GET: Stored
 public ActionResult Index()
 {
     using (var db = new DemoFPTEntities())
     {
         var list = db.Products.SqlQuery("sp_GetAll_Products").ToList();
         return(View(list));
     }
 }
Exemple #4
0
 public ActionResult Update(Product product)
 {
     using (var db = new DemoFPTEntities())
     {
         db.sp_Update_Product(product.Id, product.Name, product.Manufacture, product.CreatedBy, product.Active,
                              product.Description, DateTime.Now, product.UpdateBy, product.Deleted);
         return(RedirectToAction("Index"));
     }
 }
Exemple #5
0
 public ActionResult Insert(Product product)
 {
     using (var db = new DemoFPTEntities())
     {
         db.sp_Insert_Product(product.Name, product.Manufacture, product.CreatedBy, product.Active,
                              product.Description, DateTime.Now);
         return(RedirectToAction("Index"));
     }
 }
Exemple #6
0
 public ActionResult Details(int id)
 {
     using (var db = new DemoFPTEntities())
     {
         //var product = db.Products.FirstOrDefault(x => x.Id == id);
         var product = db.sp_GetById_Product(id);
         return(View(product));
     }
 }