Beispiel #1
0
 public ActionResult Create(ClsProduct model)
 {
     using (CMPSEntities5 dbcontext = new CMPSEntities5())
     {
         if (model.Id == 0)
         {
             Product_Details tblCustomer = new Product_Details();
             tblCustomer.ModelPlace = model.ModelPlace;
             tblCustomer.Rate       = model.Rate;
             tblCustomer.ProductId  = model.ProductId;
             dbcontext.Product_Details.Add(tblCustomer);
             dbcontext.SaveChanges();
         }
     }
     return(RedirectToAction("Index"));
 }
Beispiel #2
0
 public ActionResult Update(ClsProduct model)
 {
     using (CMPSEntities5 dbcontext = new CMPSEntities5())
     {
         if (model.Id > 0)
         {
             Product_Details tblCustomer = dbcontext.Product_Details.Where(a => a.Id == model.Id).FirstOrDefault();
             if (tblCustomer != null)
             {
                 tblCustomer.ModelPlace = model.ModelPlace;
                 tblCustomer.Rate       = model.Rate;
                 dbcontext.SaveChanges();
             }
         }
     }
     return(RedirectToAction("Index"));
 }
Beispiel #3
0
        public JsonResult InsertProducts(List <Product_Details> products)
        {
            using (CMPSEntities5 entities = new CMPSEntities5())
            {
                //Truncate Table to delete all old records.
                //entities.Database.ExecuteSqlCommand("TRUNCATE TABLE [product]");


                //Check for NULL.
                if (products == null)
                {
                    products = new List <Product_Details>();
                }

                //Loop and insert records.
                foreach (Product_Details Product in products)
                {
                    entities.Product_Details.Add(Product);
                }

                int insertedRecords = entities.SaveChanges();
                return(Json(insertedRecords));
            }
        }