public ActionResult Get()
        {
            if (objAutorized.ValidateTokenResult == null)
            {
                return(Ok(new CommonResponse()
                {
                    error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid access."
                }));
            }
            if (objAutorized.ValidateTokenResult.isValid == false)
            {
                return(Ok(new CommonResponse()
                {
                    error_code = Convert.ToInt32(ErrorCode.Failure), message = objAutorized.ValidateTokenResult.error_message
                }));
            }

            ProductAttributeDBAccess     obj         = ProductAttributeDBAccess.getInstance;
            List <ProductAttributeTable> objListData = obj.GetALLProductAttribute();

            return(Ok(
                       new ProductAttributeResponse.SelectData()
            {
                data = objListData,
                error_code = Convert.ToInt32(ErrorCode.Success),
                message = "Product attribute value data found."
            }
                       ));
        }
 public ActionResult Get(int id)
 {
     try
     {
         if (objAutorized.ValidateTokenResult == null)
         {
             return(Ok(new CommonResponse()
             {
                 error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid access."
             }));
         }
         if (objAutorized.ValidateTokenResult.isValid == false)
         {
             return(Ok(new CommonResponse()
             {
                 error_code = Convert.ToInt32(ErrorCode.Failure), message = objAutorized.ValidateTokenResult.error_message
             }));
         }
         ProductAttributeDBAccess     obj         = ProductAttributeDBAccess.getInstance;
         List <ProductAttributeTable> objListData = obj.GetProductAttributeByProductId(id);
         if (objListData.Count == 0)
         {
             return(Ok(new CommonResponse()
             {
                 error_code = Convert.ToInt32(ErrorCode.Failure), message = "Attribute value not found for product id."
             }));
         }
         return(Ok(
                    new ProductAttributeResponse.SelectData()
         {
             data = objListData,
             error_code = Convert.ToInt32(ErrorCode.Success),
             message = "Product attribute value data found."
         }
                    ));
     }
     catch (Exception ex)
     {
         return(Ok(new CommonResponse()
         {
             error_code = Convert.ToInt32(ErrorCode.Failure), message = ex.Message
         }));
     }
 }
        public ActionResult Delete(ProductAttributeDeleteParam objProductAttributeDeleteParam)
        {
            try
            {
                if (objAutorized.ValidateTokenResult == null)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid access."
                    }));
                }
                if (objAutorized.ValidateTokenResult.isValid == false)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = objAutorized.ValidateTokenResult.error_message
                    }));
                }
                if (objProductAttributeDeleteParam.AttributeId < 0)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid attribute id."
                    }));
                }
                if (objProductAttributeDeleteParam.ProductId < 0)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid attribute id."
                    }));
                }

                ProductAttributeDBAccess obj = ProductAttributeDBAccess.getInstance;
                List <ProductAttributeResponse.DeleteData> objListData = obj.DeleteProductAttribute(objProductAttributeDeleteParam.AttributeId, objProductAttributeDeleteParam.ProductId);
                if (objListData.Count == 0)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = "No data found."
                    }));
                }

                if (objListData[0].RowEffect == 0)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = objListData[0].message
                    }));
                }

                return(Ok(new ProductAttributeResponse.DeleteData()
                {
                    error_code = Convert.ToInt32(ErrorCode.Success),
                    message = objListData[0].message,
                    RowEffect = objListData[0].RowEffect
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new CommonResponse()
                {
                    error_code = Convert.ToInt32(ErrorCode.Failure), message = ex.Message
                }));
            }
        }
        public ActionResult Put(ProductAttributeUpdateParam objProductUpdateParam)
        {
            try
            {
                if (objAutorized.ValidateTokenResult == null)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = "Invalid access."
                    }));
                }
                if (objAutorized.ValidateTokenResult.isValid == false)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = objAutorized.ValidateTokenResult.error_message
                    }));
                }
                ProductAttributeTable objProduct = new ProductAttributeTable();
                objProduct.AttributeId    = objProductUpdateParam.AttributeId;
                objProduct.ProductId      = objProductUpdateParam.ProductId;
                objProduct.AttributeValue = objProductUpdateParam.AttributeValue;
                ValidationContext vc    = new ValidationContext(objProduct);
                var  validationsResults = new List <ValidationResult>();
                bool correct            = Validator.TryValidateObject(objProduct, vc, validationsResults, true);
                if (!correct)
                {
                    string errorMessage = "";
                    foreach (var item in validationsResults.Select(ov => ov.ErrorMessage))
                    {
                        errorMessage = string.Concat(errorMessage, item);
                    }
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = errorMessage
                    }));
                }
                ProductAttributeDBAccess obj = ProductAttributeDBAccess.getInstance;
                List <ProductAttributeResponse.UpdateData> objListData = obj.UpdateProductAttribute(objProduct);
                if (objListData.Count == 0)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = "No data update."
                    }));
                }

                if (objListData[0].RowEffect == 0)
                {
                    return(Ok(new CommonResponse()
                    {
                        error_code = Convert.ToInt32(ErrorCode.Failure), message = objListData[0].message
                    }));
                }

                return(Ok(new ProductAttributeResponse.UpdateData()
                {
                    error_code = Convert.ToInt32(ErrorCode.Success),
                    message = objListData[0].message,
                    RowEffect = objListData[0].RowEffect
                }));
            }
            catch (Exception ex)
            {
                return(Ok(new CommonResponse()
                {
                    error_code = Convert.ToInt32(ErrorCode.Failure), message = ex.Message
                }));
            }
        }