Exemple #1
0
 public ActionResult Post([FromBody] Product1 Product1_var)
 {
     try
     {
         context.Product1.Add(Product1_var);
         context.SaveChanges();
         return(Ok());
     }
     catch (Exception ex)
     {
         string errormissage = ex.ToString();
         return(BadRequest());
     }
 }
Exemple #2
0
 public ActionResult Put(int id, [FromBody] Product1 Product1_var)
 {
     try
     {
         if (Product1_var.Product_ID == id)
         {
             context.Entry(Product1_var).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
             context.SaveChanges();
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemple #3
0
 public ActionResult Delete(int id)
 {
     try
     {
         Product1 Product1_reg = context.Product1.FirstOrDefault(x => x.Product_ID == id);
         if (Product1_reg != null)
         {
             context.Product1.Remove(Product1_reg);
             context.SaveChanges();
             return(Ok());
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemple #4
0
        public Product1 Get(int id)
        {
            Product1 Product1_var = context.Product1.FirstOrDefault(x => x.Product_ID == id);

            return(Product1_var);
        }