Esempio n. 1
0
        public BaseResponse UpdateProduct(ProductModelRequest entity)
        {
            try
            {
                var productEntity = entity.MapTo <ProductEntity>();
                var productmodel  = productRepository.GetProduct(productEntity.ProductId);

                if (productmodel == null)
                {
                    return new BaseResponse {
                               IsSuccess = false, Msg = "can not find mddel"
                    }
                }
                ;


                bool result = productRepository.UpdateProduct(productmodel);

                return(result ? new BaseResponse {
                    IsSuccess = true
                } : new BaseResponse {
                    IsSuccess = false
                });
            }
            catch (Exception ex)
            {
                return(new BaseResponse {
                    IsSuccess = false, Msg = ex.Message
                });
            }
        }
Esempio n. 2
0
        public BaseResponse DeleteProduct(ProductModelRequest entity)
        {
            try
            {
                var productEntity = entity.MapTo<ProductEntity>();
                productRepository.DeleteProduct(productEntity);

                return new BaseResponse { IsSuccess = true };
            }
            catch (Exception ex)
            {
                return new BaseResponse { IsSuccess = false, Msg = ex.Message };
            }
        }
Esempio n. 3
0
        public ProductModelResponse AddProduct(ProductModelRequest entity)
        {
            try
            {
                var productEntity = entity.MapTo<ProductEntity>();
               
                long id = productRepository.AddProduct(productEntity);

                return id > 0 ? new ProductModelResponse { ProductId = id, IsSuccess = true } : new ProductModelResponse { IsSuccess = false, ProductId = 0 };
            }
            catch(Exception ex)
            {
                return new ProductModelResponse { ProductId = 0, IsSuccess = false, Msg = ex.Message };
            }

        }
Esempio n. 4
0
        public BaseResponse DeleteProduct(ProductModelRequest entity)
        {
            try
            {
                var productEntity = entity.MapTo <ProductEntity>();
                productRepository.DeleteProduct(productEntity);

                return(new BaseResponse {
                    IsSuccess = true
                });
            }
            catch (Exception ex)
            {
                return(new BaseResponse {
                    IsSuccess = false, Msg = ex.Message
                });
            }
        }
Esempio n. 5
0
        public BaseResponse UpdateProduct(ProductModelRequest entity)
        {
            try
            {
                var productEntity = entity.MapTo<ProductEntity>();
                var productmodel = productRepository.GetProduct(productEntity.ProductId);

                if (productmodel == null)
                    return new BaseResponse { IsSuccess = false, Msg = "can not find mddel" };

             
                bool result = productRepository.UpdateProduct(productmodel);

                return result ? new BaseResponse { IsSuccess = true } : new BaseResponse { IsSuccess = false};
            }
            catch (Exception ex)
            {
                return new BaseResponse { IsSuccess = false, Msg = ex.Message };
            }
        }
Esempio n. 6
0
        public ProductModelResponse AddProduct(ProductModelRequest entity)
        {
            try
            {
                var productEntity = entity.MapTo <ProductEntity>();

                long id = productRepository.AddProduct(productEntity);

                return(id > 0 ? new ProductModelResponse {
                    ProductId = id, IsSuccess = true
                } : new ProductModelResponse {
                    IsSuccess = false, ProductId = 0
                });
            }
            catch (Exception ex)
            {
                return(new ProductModelResponse {
                    ProductId = 0, IsSuccess = false, Msg = ex.Message
                });
            }
        }