async Task <bool?> IMovieCreateRepository.CreateAsync(MovieModel movieModel)
        {
            try
            {
                var flag =
                    await
                    sqlClientDbProvider
                    ?.DapperBuilder
                    ?.OpenConnection(sqlClientDbProvider.GetConnection())
                    ?.Parameter(async() => await base.SetParameterAsync("Add", movieModel))
                    ?.Command(async(dbConnection, dynamicParameter) => await this.ExecuteCommandAsync(movieModel, dbConnection, dynamicParameter))
                    ?.ResultAsync <bool?>();

                if (flag == true)
                {
                    DataEventStoreHandler?.Invoke(this, movieModel);
                }

                return(flag);
            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
        async Task <bool?> IMovieUpdateRepository.UpdateAsync(MovieModel movieModel)
        {
            MovieModel oldMovieModel = null;

            try
            {
                var flag =
                    await
                    sqlClientDbProvider
                    ?.DapperBuilder
                    ?.OpenConnection(sqlClientDbProvider.GetConnection())
                    ?.Parameter(async() => await base.SetParameterAsync("Update", movieModel))
                    ?.Command(async(dbConnection, dynamicParameter) =>
                {
                    (bool flag, MovieModel oldMovieModel)tupleObj = await this.ExecuteCommandAsync(movieModel, dbConnection, dynamicParameter);
                    oldMovieModel = tupleObj.oldMovieModel;
                    return(tupleObj.flag);
                })
                    ?.ResultAsync <bool?>();

                if (flag == true)
                {
                    DataEventStoreHandler?.Invoke(this, oldMovieModel, movieModel);
                }

                return(flag);
            }
            catch
            {
                throw;
            }
        }