public async Task <IActionResult> PutCreditUnion(int id, ApiCreditUnion creditUnion) { if (id != creditUnion.UnionId) { return(BadRequest("Credit Union does not exist.")); } var resource = ApiMapper.MapUnion(creditUnion); try { await _repo.UpdateCreditUnionAsync(resource); } catch (DbUpdateConcurrencyException) { if (!await _repo.CreditUnionExistAsync(id)) { return(NotFound("Credit Union not found.")); } else { throw; } } return(Ok("Credit Union updated!")); }
public async Task <ActionResult> PostCreditUnion(ApiCreditUnion creditUnion) { try { var resource = ApiMapper.MapUnion(creditUnion); await _repo.AddCreditUnionAsync(resource); return(Ok("Credit Union has been added!")); } catch (Exception) { return(BadRequest("Something went wrong")); } }