Exemple #1
0
        public async Task <ProductEntityDomain> CreateProductAsync(ProductEntityDomain product)
        {
            await _productSqlDataContext.Connection.OpenAsync();

            using (var trans = _productSqlDataContext.Connection.BeginTransaction())
            {
                try
                {
                    await _productSqlDataContext.Connection.InsertAsync(ProductEntityData.ToEntityData(product), trans);

                    trans.Commit();
                    _productSqlDataContext.Connection.Close();
                }
                catch (System.Exception)
                {
                    trans.Rollback();
                    _productSqlDataContext.Connection.Close();
                }
            }

            return(product);
        }
Exemple #2
0
        public async Task <bool> UpdateProductAsync(ProductEntityDomain product)
        {
            var resultUpdate = await _productSqlDataContext.Connection.UpdateAsync <ProductEntityData>(ProductEntityData.ToEntityData(product));

            return(resultUpdate);
        }
Exemple #3
0
        public async Task <ProductEntityDomain> GetProductAsync(string id)
        {
            var resultData = await _productSqlDataContext.Connection.GetAsync <ProductEntityData>(id);

            return(ProductEntityData.ToEntityDomain(resultData));
        }
Exemple #4
0
        public async Task <List <ProductEntityDomain> > GetAllProductsAsync()
        {
            var resultData = await _productSqlDataContext.Connection.GetAllAsync <ProductEntityData>();

            return(resultData.Select(r => ProductEntityData.ToEntityDomain(r)).ToList());
        }