// GET: Compare/Edit/5 public async Task <IActionResult> Edit(int id, string accountNo, string withdrawalDate) { try { AccountB receivedAccountB = new AccountB(); receivedAccountB.Id = id; receivedAccountB.AccountNo = accountNo; receivedAccountB.WithdrawalDate = withdrawalDate; using (var httpClient = new HttpClient()) { var content = JsonConvert.SerializeObject(receivedAccountB); var request = new StringContent(content, Encoding.UTF8, "application/json"); await httpClient.PutAsync("https://localhost:44345/api/AccountBsAPI/" + id, request); } } catch (DbUpdateConcurrencyException) { if (!AccountBExists(id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Edit(int id, [Bind("Id,AccountNo,WithdrawalDate")] AccountB accountB) { if (id != accountB.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(accountB); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountBExists(accountB.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(accountB)); }
public async Task <IActionResult> PutAccountB([FromRoute] int id, [FromBody] AccountB accountB) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != accountB.Id) { return(BadRequest()); } _context.Entry(accountB).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AccountBExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,AccountNo,WithdrawalDate")] AccountB accountB) { if (ModelState.IsValid) { _context.Add(accountB); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(accountB)); }
public async Task <IActionResult> PostAccountB([FromBody] AccountB accountB) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.AccountB.Add(accountB); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAccountB", new { id = accountB.Id }, accountB)); }