public ActionResult <SupplierProcessNpractice> GetById(int id) { if (id <= 0) { return(NotFound("Process id must be higher than zero")); } SupplierProcessNpractice company = _CompanyContext.SupplierProcessNpractice.FirstOrDefault(s => s.ProcessId == id); if (company == null) { return(NotFound("Process not found")); } return(Ok(company)); }
public async Task <ActionResult> Post([FromBody] SupplierProcessNpractice company) { if (company == null) { return(NotFound("Process data is not supplied")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _CompanyContext.SupplierProcessNpractice.AddAsync(company); await _CompanyContext.SaveChangesAsync(); return(Ok(company)); }
public async Task <ActionResult> Delete(int?id) { if (id == null) { return(NotFound("Id is not supplied")); } SupplierProcessNpractice company = _CompanyContext.SupplierProcessNpractice.FirstOrDefault(s => s.ProcessId == id); if (company == null) { return(NotFound("No Company found with particular id supplied")); } _CompanyContext.SupplierProcessNpractice.Remove(company); await _CompanyContext.SaveChangesAsync(); return(Ok("Process is deleted sucessfully.")); }