public JsonResponse NewProduct(Product Product) { JsonResponse json = new JsonResponse(); if (ModelState.IsValid) { if (!(Product == null)) { json.Data = db.Products.Add(Product); db.SaveChanges(); return(json); } } json.Message = "Unsuccessful. Please see error message"; json.Result = "Failed"; json.Error = db.Products.Add(Product); return(json); }
public JsonResponse NewCustomer(Customer customer) { JsonResponse json = new JsonResponse(); if (ModelState.IsValid) { if (!(customer == null)) { json.Data = db.Customers.Add(customer); db.SaveChanges(); return(json); } } json.Message = "Unsuccessful. Please see error message"; json.Result = "Failed"; json.Error = db.Customers.Add(customer); return(json); }
public JsonResponse NewEmployee(Employee Employee) { JsonResponse json = new JsonResponse(); if (ModelState.IsValid) { if (!(Employee == null)) { json.Data = db.Employees.Add(Employee); db.SaveChanges(); return(json); } } json.Message = "Unsuccessful. Please see error message"; json.Result = "Failed"; json.Error = db.Employees.Add(Employee); return(json); }