public async Task <IActionResult> Create([FromBody] SaveCounterResource counterResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var counter = mapper.Map <SaveCounterResource, Counter>(counterResource); counterRepository.Add(counter); if (await unitOfWork.CompleteAsync() == false) { throw new Exception(message: $"Create New Counter failed on Save"); } counter = await counterRepository.GetOne(counter.Id); var result = mapper.Map <Counter, ViewCounterResource>(counter); return(Ok(result)); }