Exemple #1
0
        /// <summary>
        /// Converts the data set to product user entity.
        /// </summary>
        /// <param name="dataSet">The data set.</param>
        /// <returns></returns>
        private static ProductUserEntity ConvertDataSetToProductUserEntity(DataSet dataSet)
        {
            ProductUserEntity productUserEntity = null;

            foreach (DataRow dataRow in dataSet.Tables[0].Rows)
            {
                productUserEntity = 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)
                    },
                    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(productUserEntity);
        }
Exemple #2
0
        /// <summary>
        /// Converts the product user entity to product user model.
        /// </summary>
        /// <param name="productUserEntity">The product user entity.</param>
        /// <returns></returns>
        private static ProductUserModel ConvertProductUserEntityToProductUserModel(ProductUserEntity productUserEntity)
        {
            var response = productUserEntity == null ? null : new ProductUserModel
            {
                ProductUserId   = productUserEntity.ProductUserId,
                ProductUserCode = productUserEntity.ProductUserCode,
                FirstName       = productUserEntity.FirstName,
                LastName        = productUserEntity.LastName,
                MobileNumber    = productUserEntity.MobileNumber,
                EmailAddress    = productUserEntity.EmailAddress,

                IsSuccess = productUserEntity.IsSuccess,
                Message   = productUserEntity.Message
            };

            if (response != null && productUserEntity.Product != null)
            {
                response.Product = new ProductModel
                {
                    IsSuccess          = true,
                    Message            = string.Empty,
                    ProductCode        = productUserEntity.Product.ProductCode,
                    ProductDescription = productUserEntity.Product.ProductDescription,
                    ProductId          = productUserEntity.Product.ProductId
                };
            }

            return(response);
        }
Exemple #3
0
 /// <summary>
 /// Manages the product user.
 /// </summary>
 /// <param name="productUserEntity">The product user entity.</param>
 /// <returns></returns>
 public ProductUserEntity ManageProductUser(ProductUserEntity productUserEntity)
 {
     try
     {
         return(ConvertDataSetToProductUserEntity(InitializeProductUserDataProcess.ManageProductUser(productUserEntity.Product.ProductCode, productUserEntity.ProductUserCode, productUserEntity.FirstName, productUserEntity.LastName, productUserEntity.EmailAddress, productUserEntity.MobileNumber)));
     }
     catch (Exception exception)
     {
         return(new ProductUserEntity {
             IsSuccess = false, Message = exception.Message == BusinessLogicResource.EMAIL_ADDRESS_ALREADY_EXISTS ? BusinessLogicResource.ERROR_EMAIL_ADDRESS_ALREADY_EXISTS : exception.InnerException?.Message ?? exception.Message
         });
     }
 }
Exemple #4
0
        public bool Add(ProductUserEntity entity)
        {
            var description = "添加用户";

            try
            {
                var sql  = "insert into ProductUser(ResourceOwner) values(@ResourceOwner)";
                var para = new List <SqlParameter>
                {
                    new SqlParameter("@ResourceOwner", entity.ResourceOwner)
                };
                return(Rponey.DbHelper.DataBaseManager.MainDb().ExecuteNonQuery(sql, para.ToArray()) > 0);
            }
            catch (Exception ex)
            {
                RPoney.Log.LoggerManager.Error(GetType().Name, $"{description}异常", ex);
                return(false);
            }
        }
 public bool Add(ProductUserEntity entity)
 {
     return(_productUserDal.Value.Add(entity));
 }