public async Task <IActionResult> Create([FromForm] RankCreateModel createModel) { try { var isEffected = await _rankService.CreateAsync(createModel); return(RedirectToAction(nameof(Index))); } catch { return(View(createModel)); } }
public async Task <ActionResult <RankDTO> > CreateAsync([FromBody] RankCreateDTO model) { try { return(Ok(await rankService.CreateAsync(model))); } catch (ValidationException e) { return(BadRequest(e.ValidationErrors)); } catch (NotFoundException e) { return(NotFound(new { Id = e.Key, e.Message })); } }