public async Task <IActionResult> PostEditCardDetailsApi(int id, [FromBody] CardDetails cardDetails) { if (ModelState.IsValid) { try { cardDetails.CardId = id; _context.Update(cardDetails); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CardDetailsExists(cardDetails.CardId)) { return(NotFound()); } else { throw; } } return(Json("Success")); } return(Json("Fail")); }
public async Task <IActionResult> Edit(int id, [Bind("CardId,Type,Digits,ExpirationMonth,ExpirationYear")] CardDetails cardDetails) { if (id != cardDetails.CardId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cardDetails); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CardDetailsExists(cardDetails.CardId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cardDetails)); }
// [FromBody]dynamic cardDetails public async Task <IActionResult> PostAddCardDetailsApi([FromBody] CardDetails cardDetails) { Console.WriteLine(cardDetails); _context.Add(cardDetails); await _context.SaveChangesAsync(); return(Json(cardDetails.CardId)); }
public async Task <IActionResult> Create([Bind("CardId,Type,Digits,ExpirationMonth,ExpirationYear")] CardDetails cardDetails) { if (ModelState.IsValid) { _context.Add(cardDetails); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cardDetails)); }
public async Task <IActionResult> PostAddCardDetailsValidationApi([FromBody] CardDetails cardDetails) { if (ModelState.IsValid) { _context.Add(cardDetails); await _context.SaveChangesAsync(); return(Json(cardDetails.CardId)); } else { return(Json("Fail")); } }