/// <summary> /// /// </summary> /// <param name="picture"></param> /// <returns></returns> public async Task <HRSubmitPictureListItem> AddPictureAsync(HRSubmitPictureInput picture) { if (picture == null || picture.Id == null || picture.Id == Guid.Empty) { throw new ArgumentNullException(); } String cxString = _config.GetConnectionString(CONNECTION_STRING_KEY); cxString = String.Format(cxString, _config[_DBUSER], _config[_DBPASSWORD]); using var conn = new NpgsqlConnection(cxString); conn.Open(); try { using Task <int> retourTask = conn.ExecuteAsync(SQLINSERT_PICTURE, picture); await retourTask; if (retourTask.IsCompletedSuccessfully) { using var getTask = GetSubmittedPicturesByIDAsync(picture.Id.ToString()); await getTask; if (getTask.IsCompletedSuccessfully) { return(getTask.Result); } else { throw new Exception("GetSubmittedPicturesByIDAsync : Can not complete Task."); } } else { throw new Exception("ExecuteAsync : Can not complete Task."); } } catch (Exception ex) { if (_logger != null) { _logger.LogError(ex.Message); } throw; } }
/// <summary> /// /// </summary> /// <param name="picture"></param> /// <returns></returns> public async Task <HRSubmitPictureInput> UpdatePictureAsync(HRSubmitPictureInput picture) { if (picture == null || picture.Id == Guid.Empty || picture.AgeType == Guid.Empty || picture.GenderType == Guid.Empty || picture.SourceType == Guid.Empty) { throw new ArgumentNullException(); } String cxString = _config.GetConnectionString(CONNECTION_STRING_KEY); cxString = String.Format(cxString, _config[_DBUSER], _config[_DBPASSWORD]); using var conn = new NpgsqlConnection(cxString); conn.Open(); try { using Task <int> retourTask = conn.ExecuteAsync(SQLUPDATE_PICTURE, picture); await retourTask; if (retourTask.IsCompletedSuccessfully) { return(picture); } else { throw new Exception("ExecuteAsync : Can not complete Task."); } } catch (Exception ex) { if (_logger != null) { _logger.LogError(ex.Message); } throw; } }
public async Task <string> AddPictureAsync(HRSubmitPictureInput rawDataPicture) { await Task.Delay(1); return(Guid.NewGuid().ToString() + ".jpg"); }