Exemple #1
0
        public async Task <IActionResult> UpdateScriptTypeAsync([FromBody] UpdateScriptTypeModel Model, int Id)
        {
            _logger.LogInformation("Update script type with id : {id}", Id);
            try
            {
                ScriptType scriptType        = _mapper.Map <ScriptType>(Model);
                ScriptType updatedScriptType = await _scriptService.UpdateTypeById(Id, scriptType);

                return(Ok(_mapper.Map <ScriptTypeModel>(updatedScriptType)));
            }
            catch (AppException ex)
            {
                _logger.LogWarning(ex, "Failed to update script type");
                return(BadRequest(new { message = ex.Message }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Fatal failure during scrip type update");
                return(StatusCode(StatusCodes.Status500InternalServerError, new { message = "Fatal internal error. Please contact administrator" }));
            }
        }