public List <ProductAttributeLookupResponse.InsertData> InsertProductAttributeLookup(ProductAttributeLookupTable objProductAttributeLookupTable)
        {
            List <ProductAttributeLookupResponse.InsertData> getProductCategoryList = new List <ProductAttributeLookupResponse.InsertData>();

            try
            {
                var values = new { ProdCatId = objProductAttributeLookupTable.ProdCatId, AttributeName = objProductAttributeLookupTable.AttributeName, Action = "1" };
                using (IDbConnection con = new SqlConnection(ConString.GetConnectionString))
                {
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }

                    getProductCategoryList = con.Query <ProductAttributeLookupResponse.InsertData>("[dbo].[InsertOrUpdateOrDeleteProductAttributeLookup]", values, commandType: CommandType.StoredProcedure).ToList();
                }
                return(getProductCategoryList);
            }
            catch (Exception)
            {
                return(getProductCategoryList);
            }
        }
Exemplo n.º 2
0
        public ActionResult Put(ProductAttributeLookupUpdateParam 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
                    }));
                }
                ProductAttributeLookupTable objProduct = new ProductAttributeLookupTable();
                objProduct.AttributeId   = objProductUpdateParam.AttributeId;
                objProduct.ProdCatId     = objProductUpdateParam.ProdCatId;
                objProduct.AttributeName = objProductUpdateParam.AttributeName;
                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
                    }));
                }
                ProductAttributeLookupDBAccess obj = ProductAttributeLookupDBAccess.getInstance;
                List <ProductAttributeLookupResponse.UpdateData> objListData = obj.UpdateProductAttributeLookup(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 ProductAttributeLookupResponse.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
                }));
            }
        }