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()); } }
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()); } }
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()); } }
public Product1 Get(int id) { Product1 Product1_var = context.Product1.FirstOrDefault(x => x.Product_ID == id); return(Product1_var); }