public void Delete(ProductT entity)
 {
     Connection.Execute(
         @"DELETE FROM ProductT WHERE ProductID = @ProductID
                    DELETE FROM CompanyT_ProductT WHERE ProductID = @ProductID",
         param: new { ProductID = entity.ProductID }, transaction: Transaction);
 }
        public void Add(ProductT entity)
        {
            Connection.Execute(@"
                            INSERT INTO ProductT(
                                ProductName,
                                ProductType,
                                Price,
                                Unit)
                            VALUES(
                                @ProductName,
                                @ProductType,
                                @Price,
                                @Unit)
                            DECLARE @LastID int
                            SELECT @LastID =  SCOPE_IDENTITY()

                            INSERT INTO CompanyT_ProductT(
                                CompanyID,
                                ProductID 
                            ) VALUES(
                                @CompanyID,
                                @LastID 
                            )", param: new
            {
                CompanyID   = entity.CompanyID,
                ProductName = entity.ProductName,
                ProductType = entity.ProductType,
                Price       = entity.Price,
                Unit        = entity.Unit
            }, transaction: Transaction);
        }
Exemple #3
0
        public Jsend <ProductT> FindProductByName(string name)
        {
            ProductT result = null;

            try
            {
                result = _uow.ProductTRepository.FindByName(name);
                _uow.Commit();
            }
            catch (SqlException ex)
            {
                _logger.Error(ex);
                return(JsendResult <ProductT> .Error("FindProductByName() occured error"));
            }
            return(JsendResult <ProductT> .Success(result));
        }
Exemple #4
0
        //public Jsend<OneToManyMap<ProductT>> FindAll(int currentPage, int itemsPerPages, bool isDesc = false)
        //{
        //    OneToManyMap<ProductT> result = null;

        //    try
        //    {
        //        result = _uow.ProductTRepository.FindAll(currentPage, itemsPerPages, isDesc);
        //        _uow.Commit();
        //    }
        //    catch (SqlException ex)
        //    {
        //        _logger.Error(ex);
        //        return JsendResult<OneToManyMap<ProductT>>.Error("");
        //    }
        //    return JsendResult<OneToManyMap<ProductT>>.Success(result);
        //}

        public Jsend <ProductT> FindProductByID(int id)
        {
            ProductT result = null;

            try
            {
                result = _uow.ProductTRepository.FindByID(id);
                _uow.Commit();
            }
            catch (SqlException ex)
            {
                _logger.Error(ex);
                return(JsendResult <ProductT> .Error(""));
            }
            return(JsendResult <ProductT> .Success(result));
        }
 public void Update(ProductT entity)
 {
     Connection.Execute(
         @"UPDATE ProductT 
         SET ProductName = @ProductName,
             ProductType = @ProductType,
             Price = @Price,
             Unit  = @Unit
         WHERE ProductID = @ProductID",
         param: new
     {
         ProductID   = entity.ProductID,
         ProductName = entity.ProductName,
         ProductType = entity.ProductType,
         Price       = entity.Price,
         Unit        = entity.Unit
     }, transaction: Transaction);
 }