Example #1
0
        public SubCategory1Dto Save(SubCategory1Dto dto)
        {
            try
            {
                CategoryDto category;

                if (!string.IsNullOrEmpty(dto.Category.Name))
                {
                    category = new CategoryLogic().GetByName(dto.Category.Name);
                }
                else
                {
                    category = new CategoryDto {
                        Id = dto.Category.Id
                    };
                }

                var retVal = this.dal.Save(dto.Id, dto.Name, category.Id).ToDto();
                return(retVal);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #2
0
        public ProductTypeDto Save(ProductTypeDto dto)
        {
            try
            {
                var categoryLogic = new CategoryLogic();
                var brandLogic    = new BrandLogic();

                var categories = categoryLogic.GetByNames(dto.Categories.Select(c => c.Name).ToList());
                var brands     = brandLogic.GetByNames(dto.Brands.Select(b => b.Name).ToList());
                var retVal     = this.dal.Save(dto.Id, dto.Name, categories.Select(c => c.Id).ToList(), brands.Select(b => b.Id).ToList()).ToDto();
                return(retVal);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }