// api/paymentOption public IActionResult Post([FromBody] PaymentOptionDto model) { if (ModelState.IsValid) { var paymentOption = _iMapper.Map <PaymentOption>(model); bool isAdded = _iPaymentOptionManager.Add(paymentOption); if (isAdded) { return(Ok(paymentOption)); } return(BadRequest(new { error = "Failed To Add!!" })); } return(BadRequest(new { error = "Model State Is Not Valid!" })); }
public IActionResult Put(int id, [FromBody] PaymentOptionDto model) { var retriveItem = _iPaymentOptionManager.GetById(id); if (retriveItem == null) { return(BadRequest(new { error = "Can Not Found Data!!" })); } var paymentOption = _iMapper.Map <PaymentOption>(model); retriveItem.Name = paymentOption.Name; retriveItem.Description = paymentOption.Description; retriveItem.IsDelete = paymentOption.IsDelete; var isUpdate = _iPaymentOptionManager.Update(retriveItem); if (!isUpdate) { return(BadRequest(new { error = "Failed to add Update!!" })); } return(Ok(retriveItem)); }