public JSONResponse Create(PurchaseRequestLineItem purchaserequestlineitem)
 {
     if (purchaserequestlineitem == null)
     {
         return(new JSONResponse {
             Result = "failed",
             Message = "Failed to create becasue null"
         });
     }
     if (!ModelState.IsValid)
     {
         return(new JSONResponse {
             Result = "failed",
             Message = "Model state is invalid, see error",
             Error = ModelState
         });
     }
     purchaserequestlineitem.Product         = null;
     purchaserequestlineitem.PurchaseRequest = null;
     db.PurchaseRequestLineItems.Add(purchaserequestlineitem);
     db.SaveChanges();
     return(new JSONResponse {
         Message = "Success",
         Data = purchaserequestlineitem
     });
 }
Example #2
0
 public JSONResponse Create(Vendor vendor)
 {
     if (vendor == null)
     {
         return(new JSONResponse {
             Result = "failed",
             Message = "Failed to create becasue null"
         });
     }
     if (!ModelState.IsValid)
     {
         return(new JSONResponse {
             Result = "failed",
             Message = "Model state is invalid, see error",
             Error = ModelState
         });
     }
     db.Vendors.Add(vendor);
     db.SaveChanges();
     return(new JSONResponse {
         Message = "Success",
         Data = vendor
     });
 }
Example #3
0
 public JSONResponse Create(Product product)
 {
     if (product == null)
     {
         return(new JSONResponse {
             Result = "failed",
             Message = "Failed to create becasue null"
         });
     }
     if (!ModelState.IsValid)
     {
         return(new JSONResponse {
             Result = "failed",
             Message = "Model state is invalid, see error",
             Error = ModelState
         });
     }
     db.Products.Add(product);
     db.SaveChanges();
     return(new JSONResponse {
         Message = "Success",
         Data = product
     });
 }