public HttpResponseMessage GetProductById([FromBody] Models.product product)
        {
            var productId = product.product_id;

            var employee = productRepository.GetProductById(productId);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, employee);

            return(response);
        }
        public ActionResult SaveDeleteProduct(Models.product product)
        {
            PRFancyRepository dal = new PRFancyRepository();
            PRFancyAutoMapper <Models.product, product> map = new PRFancyAutoMapper <Models.product, product>();

            try
            {
                if (dal.DeleteProduct(map.Translate(product)))
                {
                    return(RedirectToAction("ViewAllProducts"));
                }
                return(View("Error"));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw;
            }
        }
        public HttpResponseMessage Delete([FromBody] Models.product product)
        {
            try
            {
                bool updatCountry = productRepository.DeleteProduct(product.product_id);

                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "success", msg = "Product Delete Successfully."
                }, formatter));
            }
            catch (Exception ex)
            {
                var formatter = RequestFormat.JsonFormaterString();
                return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                    output = "error", msg = ex.ToString()
                }, formatter));
            }
        }
        public HttpResponseMessage Put([FromBody] Models.product product)
        {
            try
            {
                // All validation Applied by Kiron : 16-11-2016

                if (string.IsNullOrEmpty(product.product_name))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Product Name is Empty"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.product_code.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Enter Product Code"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.unit_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select Unit"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.brand_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select Brand"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.product_category_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select Product Category"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.mrp_price.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select MRP Price"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.supplier_id.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select supplier for this product"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.md_price.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select Master Dealer Price"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.rp_price.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select Retailer Shop Price"
                    }, formatter));
                }
                if (string.IsNullOrEmpty(product.bs_price.ToString()))
                {
                    var formatter = RequestFormat.JsonFormaterString();
                    return(Request.CreateResponse(HttpStatusCode.OK, new Confirmation {
                        output = "error", msg = "Select Brand Shop  Price"
                    }, formatter));
                }

                else
                {
                    Models.product updateProduct = new Models.product
                    {
                        product_id              = product.product_id,
                        product_name            = product.product_name,
                        product_code            = product.product_code,
                        unit_id                 = product.unit_id,
                        brand_id                = product.brand_id,
                        product_category_id     = product.product_category_id,
                        current_balance         = product.current_balance,
                        product_image_url       = product.product_image_url,
                        has_serial              = product.has_serial,
                        has_warrenty            = product.has_warrenty,
                        warrenty_type           = product.warrenty_type,
                        warrenty_value          = product.warrenty_value,
                        vat_percentage          = product.vat_percentage,
                        tax_percentage          = product.tax_percentage,
                        rp_price                = product.rp_price,
                        md_price                = product.md_price,
                        mrp_price               = product.mrp_price,
                        bs_price                = product.bs_price,
                        specification           = product.specification,
                        remarks                 = product.remarks,
                        eol_date                = product.eol_date,
                        launce_date             = product.launce_date,
                        supplier_id             = product.supplier_id,
                        accessories_category_id = product.accessories_category_id,
                        is_active               = product.is_active
                    };

                    productRepository.EditProduct(updateProduct);


                    var formatter = RequestFormat.JsonFormaterString();

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