Ejemplo n.º 1
0
        public HttpResponseMessage Put([FromBody] Models.product_category product_category)
        {
            try
            {
                Models.product_category updateProductCategory = new Models.product_category
                {
                    product_category_id   = product_category.product_category_id,
                    product_category_name = product_category.product_category_name,
                    product_category_code = product_category.product_category_code
                };

                productCategoryRepository.EditProductCategory(updateProductCategory);


                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "success", msg = "Product Category update successfully"
                }, formatter));
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetProductCategoryById([FromBody] Models.product_category product_category)
        {
            var productCategoryId = product_category.product_category_id;

            var employee = productCategoryRepository.GetProductCategoryById(productCategoryId);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employee);

            return(response);
        }
Ejemplo n.º 3
0
        public HttpResponseMessage Delete([FromBody] Models.product_category product_category)
        {
            try
            {
                //long con_id = long.Parse(country_id);
                bool updatCountry = productCategoryRepository.DeleteProductCategory(product_category.product_category_id);

                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "success", msg = "Product Category Delete Successfully."
                }, formatter));
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
Ejemplo n.º 4
0
        public HttpResponseMessage Post([FromBody] Models.product_category product_category)
        {
            try
            {
                if (string.IsNullOrEmpty(product_category.product_category_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Name is Empty"
                    }, formatter));
                }
                else
                {
                    product_category insert_product_category = new product_category
                    {
                        product_category_name = product_category.product_category_name,
                        product_category_code = product_category.product_category_code
                    };



                    productCategoryRepository.AddProductCategory(insert_product_category);


                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "success", msg = "Product Category save successfully"
                    }, formatter));
                }
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }