public async Task <IActionResult> PutPrdProducts([FromRoute] int id, [FromBody] PrdProducts prdProducts) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != prdProducts.ProductId) { return(BadRequest()); } _context.Entry(prdProducts).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!PrdProductsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> UpdateProduct(int id, [FromBody] PrdProducts PrdProduct) { try { if (PrdProduct != null && id != 0) { using (EzyFind_DevContext db = new EzyFind_DevContext()) { db.PrdProducts.Update(PrdProduct); await db.SaveChangesAsync(); id = PrdProduct.ProductId; } response.Status = true; // Operation Status Indicator response.Message = "Successful: Product updated"; // Exception Message response.Result = id; return(Ok(response)); } else { response.Status = false; // Operation Status Indicator response.Message = "Warning : No Product provided"; // Exception Message response.Result = null; return(Ok(response)); } } catch { response.Status = false; // Operation Status Indicator response.Message = "Error : Unable to update Product"; // Exception Message response.Result = null; return(Ok(response)); } }
public async Task <IActionResult> PostPrdProducts([FromBody] PrdProducts prdProducts) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.PrdProducts.Add(prdProducts); await _context.SaveChangesAsync(); return(CreatedAtAction("GetPrdProducts", new { id = prdProducts.ProductId }, prdProducts)); }