public async Task <UpdateWebHookResponse> UpdateWebHookAsync(UpdateWebHookViewModel model) { try { //get merchant var merchant = _context.MerchantAccounts.FirstOrDefault(x => x.ApiKey == model.HashCode); if (merchant != null) { //update merchant webhook... merchant.WebHook = model.WebHookURL; _context.Entry(merchant).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(new UpdateWebHookResponse { Message = "Merchant Webhook updated successfully", IsSuccess = true }); } catch (Exception ex) { throw new NullReferenceException(ex.Message); } }
public async Task <IActionResult> UpdateWebHookAsync([FromBody] UpdateWebHookViewModel model) { if (ModelState.IsValid) { var result = await _merchantService.UpdateWebHookAsync(model); if (result.IsSuccess) { return(Ok(result)); //Status Code : 200 } return(BadRequest(result)); } return(BadRequest("Some properties are not valid")); //return code:400 }