public async Task <IActionResult> Create([FromBody] StudioCreateDTO studioDTO) { var location = GetControllerActionNames(); try { _logger.LogInfo($"{location}: Create Attempted"); if (studioDTO == null) { _logger.LogWarn($"{location}: Empty Request was submitted"); return(BadRequest(ModelState)); } if (!ModelState.IsValid) { _logger.LogWarn($"{location}: Data was Incomplete"); return(BadRequest(ModelState)); } var studio = _mapper.Map <Studio>(studioDTO); var isSuccess = await _studioRepository.Create(studio); if (!isSuccess) { return(InternalError($"{location}: Creation failed")); } _logger.LogInfo($"{location}: Creation was successful"); return(Created("Create", new { studio })); } catch (Exception e) { return(InternalError($"{location}: {e.Message} - {e.InnerException}")); } }
public Studio Post(StudioDTO value) { Studio model = new Studio() { Name = value.Name, ProviderId = value.ProviderId }; return(IStudioRepository.Create(model)); }
//TODO : Thêm mới bản ghi vào cơ sở dữ liệu public int Create(string sqlQuery, DynamicParameters param, CommandType commandType) { return(_studioRepository.Create(sqlQuery, param, commandType)); }