Пример #1
0
        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!"));
        }
Пример #2
0
        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"));
            }
        }