public int SaveProduct(ProductDO objProduct) { logger.Debug("SaveProduct Json method in Catalog Controller called-" + objProduct.ProductID); int iResult = -1; CatalogServiceClient objCatalogServiceClient = new CatalogServiceClient(); try { //int iUserProfileID = ((UserDO)SessionManager.ReadSession(UtilityConstants.SessionNames.USER)).UserProfileID; //objProduct.CreatedBy = iUserProfileID; iResult = objCatalogServiceClient.SaveProduct(objProduct); } catch (Exception objException) { logger.Error("Method SaveResource - Error." + objException.Message); } finally { objCatalogServiceClient.Close(); } return iResult; }
/// <summary> /// This method is used to get product details data by its unique ID. /// </summary> /// <param name="iProductID">ProductID as integer.</param> /// <returns>ProductDO object with details data.</returns> public ProductDO GetProductDetail(int iProductID) { ProductDO objProduct = new ProductDO(); DataSet dsProductDetail = new CatalogDA().GetProductDetail(iProductID); if (dsProductDetail.Tables.Count > 0 && dsProductDetail.Tables[0].Rows.Count > 0) { objProduct = GetProductMappedData(dsProductDetail.Tables[0].Rows[0]); } return objProduct; }
/// <summary> /// This method is used to map product data from DataRow to product object. /// </summary> /// <param name="drProduct">Product data as DataRow.</param> /// <returns>Product details data as ProductDO.</returns> private ProductDO GetProductMappedData(DataRow drProduct) { ProductDO objProduct = new ProductDO(); objProduct.ProductID = Convert.ToInt32(drProduct["PkProductId"]); objProduct.CategoryID = Convert.ToInt32(drProduct["FkCatagoryId"]); objProduct.ProductTypeID = Convert.ToInt32(drProduct["FkProductTypeId"]); objProduct.BrandID = Convert.ToInt32(drProduct["FkBrandId"]); objProduct.Name = Convert.ToString(drProduct["ProductName"]); objProduct.OnHandQuantity = Convert.ToInt32(drProduct["Quantity"]); objProduct.PurchasePrice = Convert.ToDecimal(drProduct["PurchasePrice"]); objProduct.SellingPrice = Convert.ToDecimal(drProduct["SellingPrice"]); objProduct.Description = Convert.ToString(drProduct["Description"]); objProduct.ImagePath = Convert.ToString(drProduct["ProductImage"]); return objProduct; }
/// <summary> /// This method is used to save the product /// </summary> /// <param name="objProduct">Product information as ProductDO object.</param> /// <returns>ProductID as integer.</returns> public int SaveProduct(ProductDO objProduct) { logger.Debug("Method SaveProduct - objProduct.ProductID " + objProduct.ProductID); return new CatalogDA().SaveProduct(objProduct); }
/// <summary> /// This method is used to get all the products and related data as a Dictionary object. /// </summary> /// <returns>Products and related data as Dictionary.</returns> public Dictionary<string, object> GetProducts(int iCategoryID, int iBrandID, int iProductTypeID, string strSearchText, int iPageNo, int iPageCount) { logger.Debug("Method GetProducts called."); Dictionary<string, object> dicProducts = new Dictionary<string, object>(); DataSet dsProducts = new CatalogDA().GetProducts(iCategoryID, iBrandID, iProductTypeID, strSearchText, iPageNo, iPageCount); if (dsProducts.Tables.Count > 0) { logger.Debug("Total products returned : " + dsProducts.Tables[0].Rows.Count); Dictionary<int, ProductDO> dicProduct = new Dictionary<int, ProductDO>(); ProductDO objProduct = new ProductDO(); foreach (DataRow drProduct in dsProducts.Tables[0].Rows) { objProduct = GetProductMappedData(drProduct); dicProduct.Add(objProduct.ProductID, objProduct); } dicProducts.Add("Products", dicProduct); } return dicProducts; }
/// <summary> /// This method is used to save product supplied from UI as object. /// </summary> /// <param name="objProductDO">Product as ProductDO object.</param> /// <returns>ProductID as integer.</returns> public int SaveProduct(ProductDO objProductDO) { logger.Debug("Called Method SaveProduct with parameter objProductDo : " + objProductDO.ToString()); return new CatalogBA().SaveProduct(objProductDO); }
/// <summary> /// This method is to add/update product to the database Product table. /// </summary> /// <param name="product">Product data as ProductDO class object.</param> /// <returns>ProductID as integer.</returns> public int SaveProduct( ProductDO objProduct) { try { logger.Debug("Method SaveProduct - hsProductSave."); SqlCommand objSqlCommand = null; objSqlCommand = DBBase.Execute.GetCommandObject(); objSqlCommand.CommandText = "hsProductSave";// procedure name needs to be changed. objSqlCommand.CommandType = CommandType.StoredProcedure; #region Add Parameters with Value if (objProduct.ProductID != -1) { objSqlCommand.Parameters.AddWithValue("@ModifiedBy", objProduct.ModifiedBy); objSqlCommand.Parameters.AddWithValue("@PkProductId", objProduct.ProductID); } else objSqlCommand.Parameters.AddWithValue("@ModifiedBy", objProduct.CreatedBy); objSqlCommand.Parameters.AddWithValue("@FkProductTypeId", objProduct.ProductTypeID); objSqlCommand.Parameters.AddWithValue("@FkCatagoryId", objProduct.CategoryID); objSqlCommand.Parameters.AddWithValue("@FkBrandId", objProduct.BrandID); objSqlCommand.Parameters.AddWithValue("@FkProductGroupId", 1); objSqlCommand.Parameters.AddWithValue("@FkProductAvailableStatusId", objProduct.ProductAvailableStatusID); objSqlCommand.Parameters.AddWithValue("@ProductName", objProduct.Name); objSqlCommand.Parameters.AddWithValue("@ProductBatchNumber", objProduct.BatchNo); objSqlCommand.Parameters.AddWithValue("@ExpirationDate", DateTime.Now); objSqlCommand.Parameters.AddWithValue("@Quantity", objProduct.OnHandQuantity); objSqlCommand.Parameters.AddWithValue("@PurchasePrice", objProduct.PurchasePrice); objSqlCommand.Parameters.AddWithValue("@SellingPrice", objProduct.SellingPrice); objSqlCommand.Parameters.AddWithValue("@ImagePath", objProduct.ImagePath); objSqlCommand.Parameters.AddWithValue("@Description", objProduct.Description); //objSqlCommand.Parameters.AddWithValue("@ModificationStatus", objProduct.ModificationStatus); #endregion objProduct.ProductID = Convert.ToInt32(DBBase.Execute.ExecuteScalar(objSqlCommand)); } catch(Exception objExc) { logger.Error("Method SaveProduct - Error " + objExc.ToString()); } return objProduct.ProductID; }