public async Task <IActionResult> CreateBank([FromBody] BankCreateRequestModel bank) { if (bank == null) { return(BadRequest()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var bankDto = Mapper.Map <BankCreateModel>(bank); var newBankId = await _bankService.AddAsync(bankDto); return(await GetCreatedRequestModel(bank, newBankId, "GetBank")); }
public async Task<ActionResult> PostAsync([FromBody] Banks item) { if (!ModelState.IsValid) return BadRequest(); try { var exist = await service.GetAsync(x => x.bankname == item.bankname); if (exist != null) return Conflict(new Response() { Status = false, Description = "Duplicate record" }); var result = await service.AddAsync(item); if (result) { var newitem = await service.GetAsync(x => x.bankname == item.bankname); return StatusCode(201, newitem); } else return BadRequest(); } catch (Exception ex) { logger.LogError(ex.Message); return StatusCode(500, new Response() { Status = false, Description = "System error" }); } }