Пример #1
0
 public UserDataObjectList GetUsers(QuerySpec spec)
 {
     try
     {
         return userServiceImpl.GetUsers(spec);
     }
     catch(Exception ex)
     {
         throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
     }
 }
		public ProductDataObjectList GetProducts(QuerySpec spec)
		{
			try
			{
				return _productServiceImpl.GetProducts(spec);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
Пример #3
0
 public UserDataObject GetUserByName(String userName, QuerySpec spec)
 {
     try
     {
         return userServiceImpl.GetUserByName(userName, spec);
     }
     catch(Exception ex)
     {
         throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
     }
 }
		public UserDataObject GetUserByKey(Guid id, QuerySpec spec)
		{
			try
			{
				return _userServiceImpl.GetUserByKey(id, spec);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
		public CategoryDataObject GetCategoryByID(Guid id, QuerySpec spec)
		{
			try
			{
				return _productServiceImpl.GetCategoryByID(id, spec);
			}
			catch(Exception ex)
			{
				throw new FaultException<FaultData>(FaultData.CreateFromException(ex), FaultData.CreateFaultReason(ex));
			}
		}
Пример #6
0
 /// <summary>
 /// 根据指定的ID值获取商品信息。
 /// </summary>
 /// <param name="id">商品信息ID值。</param>
 /// <param name="spec">查询方式。</param>
 /// <returns>商品信息。</returns>
 public ProductDataObject GetProductByID(Guid id, QuerySpec spec)
 {
     var product=productRepository.GetByKey(id);
     var result = Mapper.Map<Product, ProductDataObject>(product);
     if (spec != null && spec.IsVerbose())
     {
         result.Category = Mapper.Map<Category, CategoryDataObject>(categorizationRepository.GetCategoryForProduct(product));
     }
     return result;
 }
Пример #7
0
 /// <summary>
 /// 获取所有的商品信息。
 /// </summary>
 /// <param name="spec">查询方式。</param>
 /// <returns>商品信息。</returns>
 public ProductDataObjectList GetProducts(QuerySpec spec)
 {
     var result = new ProductDataObjectList();
     productRepository
         .FindAll()
         .ToList()
         .ForEach(p =>
             {
                 var dataObject = Mapper.Map<Product, ProductDataObject>(p);
                 if (spec != null && spec.IsVerbose())
                 {
                     var category = categorizationRepository.GetCategoryForProduct(p);
                     if (category != null)
                     {
                         dataObject.Category = Mapper.Map<Category, CategoryDataObject>(category);
                     }
                 }
                 result.Add(dataObject);
             });
     return result;
 }
Пример #8
0
 /// <summary>
 /// 获取所有的商品分类。
 /// </summary>
 /// <param name="spec">查询方式。</param>
 /// <returns>所有的商品分类。</returns>
 public CategoryDataObjectList GetCategories(QuerySpec spec)
 {
     CategoryDataObjectList result = null;
     var categories = categoryRepository.FindAll();
     if (categories != null)
     {
         result = new CategoryDataObjectList();
         foreach (var category in categories)
         {
             var categoryDataObject = Mapper.Map<Category, CategoryDataObject>(category);
             if (spec != null && spec.IsVerbose())
             {
                 var products = categorizationRepository.GetProductsForCategory(category);
                 if (products != null && products.Count() > 0)
                 {
                     categoryDataObject.Products = new ProductDataObjectList();
                     products.ToList()
                         .ForEach(p =>
                             {
                                 categoryDataObject.Products.Add(Mapper.Map<Product, ProductDataObject>(p));
                             });
                 }
             }
             result.Add(categoryDataObject);
         }
     }
     return result;
 }
Пример #9
0
 /// <summary>
 /// 根据指定的ID值获取商品分类。
 /// </summary>
 /// <param name="id">商品分类ID值。</param>
 /// <param name="spec">查询方式。</param>
 /// <returns>商品分类。</returns>
 public CategoryDataObject GetCategoryByID(Guid id, QuerySpec spec)
 {
     var category = categoryRepository.GetByKey(id);
     var result = Mapper.Map<Category, CategoryDataObject>(category);
     if (spec != null && spec.IsVerbose())
     {
         var products = categorizationRepository.GetProductsForCategory(category);
         if (products.Count() > 0)
         {
             result.Products = new ProductDataObjectList();
             products
                 .ToList()
                 .ForEach(p =>
                     {
                         result.Products.Add(Mapper.Map<Product, ProductDataObject>(p));
                     });
         }
     }
     return result;
 }
Пример #10
0
 /// <summary>
 /// 获取所有用户的信息。
 /// </summary>
 /// <param name="spec">查询方式。</param>
 /// <returns>包含了所有用户信息的数据传输对象列表。</returns>
 public UserDataObjectList GetUsers(QuerySpec spec)
 {
     var users = userRepository.FindAll();
     if (users == null)
         return null;
     var ret = new UserDataObjectList();
     foreach (var user in users)
     {
         var userDataObject = Mapper.Map<User, UserDataObject>(user);
         if (spec.IsVerbose())
         {
             var role = userRoleRepository.GetRoleForUser(user);
             if (role != null)
             {
                 userDataObject.Role = Mapper.Map<Role, RoleDataObject>(role);
             }
         }
         ret.Add(userDataObject);
     }
     return ret;
 }
Пример #11
0
 /// <summary>
 /// 根据用户的用户名获取用户信息。
 /// </summary>
 /// <param name="userName">用户的用户名。</param>
 /// <param name="spec">查询方式。</param>
 /// <returns>包含了用户信息的数据传输对象。</returns>
 public UserDataObject GetUserByName(string userName, QuerySpec spec)
 {
     if (string.IsNullOrEmpty(userName))
         throw new ArgumentException("userName");
     var user = userRepository.GetUserByName(userName);
     var userDataObject = Mapper.Map<User, UserDataObject>(user);
     if (spec.IsVerbose())
     {
         var role = userRoleRepository.GetRoleForUser(user);
         if (role != null)
         {
             userDataObject.Role = Mapper.Map<Role, RoleDataObject>(role);
         }
     }
     return userDataObject;
 }
Пример #12
0
 /// <summary>
 /// 根据用户的全局唯一标识获取用户信息。
 /// </summary>
 /// <param name="ID">用户的全局唯一标识。</param>
 /// <param name="spec">查询方式。</param>
 /// <returns>包含了用户信息的数据传输对象。</returns>
 public UserDataObject GetUserByKey(Guid ID, QuerySpec spec)
 {
     var user = userRepository.GetByKey(ID);
     var userDataObject = Mapper.Map<User, UserDataObject>(user);
     if (spec.IsVerbose())
     {
         var role = userRoleRepository.GetRoleForUser(user);
         if (role != null)
         {
             userDataObject.Role = Mapper.Map<Role, RoleDataObject>(role);
         }
     }
     return userDataObject;
 }