public async Task <IActionResult> UpdateModule(int id, [FromBody] SaveModuleResource moduleResource) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var module = await repository.GetModule(id); if (module == null) { return(NotFound()); } module = mapper.Map <SaveModuleResource, Module>(moduleResource, module); var exist = await repository.EditModuleExist(module); if (exist != null) { return(Conflict("Module details already exist.")); } await unitOfWork.CompleteAsync(); module = await repository.GetModule(module.Id); var result = mapper.Map <Module, ModuleResource>(module); return(Ok(result)); }