Example #1
0
        /// <summary>
        /// Converts the data set to product user collection.
        /// </summary>
        /// <param name="dataSet">The data set.</param>
        /// <returns></returns>
        private static ProductUserCollection ConvertDataSetToProductUserCollection(DataSet dataSet)
        {
            var response = new ProductUserCollection
            {
                Items     = new List <ProductUserEntity>(),
                IsSuccess = dataSet.Tables[0].Rows.Count > 0
            };

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                response.Items.Add(new ProductUserEntity
                {
                    ProductUserId = dataRow[BusinessLogicResource.ProductUserId] == DBNull.Value ? 0 : Convert.ToInt64(dataRow[BusinessLogicResource.ProductUserId], CultureInfo.InvariantCulture),
                    Product       = new ProductEntity
                    {
                        ProductId          = dataRow[BusinessLogicResource.ProductId] == DBNull.Value ? 0 : Convert.ToInt32(dataRow[BusinessLogicResource.ProductId], CultureInfo.InvariantCulture),
                        ProductCode        = dataRow[BusinessLogicResource.ProductCode] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.ProductCode], CultureInfo.InvariantCulture),
                        ProductDescription = dataRow[BusinessLogicResource.ProductDescription] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.ProductDescription], CultureInfo.InvariantCulture),
                        IsSuccess          = true
                    },
                    ProductUserCode = dataRow[BusinessLogicResource.ProductUserCode] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.ProductUserCode], CultureInfo.InvariantCulture),
                    FirstName       = dataRow[BusinessLogicResource.FirstName] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.FirstName], CultureInfo.InvariantCulture),
                    LastName        = dataRow[BusinessLogicResource.LastName] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.LastName], CultureInfo.InvariantCulture),
                    FullName        = dataRow[BusinessLogicResource.FullName] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.FullName], CultureInfo.InvariantCulture),
                    EmailAddress    = dataRow[BusinessLogicResource.EmailAddress] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.EmailAddress], CultureInfo.InvariantCulture),
                    MobileNumber    = dataRow[BusinessLogicResource.MobileNumber] == DBNull.Value ? string.Empty : Convert.ToString(dataRow[BusinessLogicResource.MobileNumber], CultureInfo.InvariantCulture),
                    IsActive        = dataRow[BusinessLogicResource.IsActive] != DBNull.Value && Convert.ToBoolean(dataRow[BusinessLogicResource.IsActive], CultureInfo.InvariantCulture),
                    IsSuccess       = true,
                    Message         = string.Empty
                });
            }


            return(response);
        }
Example #2
0
        /// <summary>
        /// Converts the product user collection to list.
        /// </summary>
        /// <param name="productUsers">The product users.</param>
        /// <returns></returns>
        private static IList <ProductUserModel> ConvertProductUserCollectionToList(ProductUserCollection productUsers)
        {
            if (productUsers?.Items == null || !productUsers.Items.Any())
            {
                return(null);
            }

            return(productUsers.Items.Select(ConvertProductUserEntityToProductUserModel).ToList());
        }