Пример #1
0
        /// <summary>
        /// To Translate Product to ProductBE
        /// </summary>
        /// <param name="productDE"></param>
        /// <returns></returns>
        public ProductBE Translate(Product productDE)
        {
            if (productDE != null)
            {
                ProductBE productBE = new ProductBE()
                {
                    ProductId    = productDE.ProductId,
                    ProductName  = productDE.ProductName,
                    ProductPrice = productDE.ProductPrice,
                    CategoryId   = productDE.CategoryId,
                    Category     = new CategoryBE()
                };

                if (productDE.Category != null)
                {
                    CategoryTranslator categoryTranslator = new CategoryTranslator();
                    productBE.Category = categoryTranslator.Translate(productDE.Category);
                }

                return(productBE);
            }
            else
            {
                return(null);
            }
        }
Пример #2
0
        /// <summary>
        /// Gets all categories.
        /// </summary>
        /// <param name="dbEntity">The db entity.</param>
        /// <returns></returns>
        public List <CategoryBE> GetAllCategories(TTAEntityContainer dbEntity)
        {
            List <CategoryBE>  listCategoryBE     = new List <CategoryBE>();
            CategoryTranslator categoryTranslator = new CategoryTranslator();

            List <Category> categoryDEList = (from Category category in dbEntity.Categories
                                              select category).ToList <Category>();

            foreach (Category categoryDE in categoryDEList)
            {
                CategoryBE categoryBE = categoryTranslator.Translate(categoryDE);
                listCategoryBE.Add(categoryBE);
            }
            return(listCategoryBE);
        }