public async Task <GetProductCategoryOutput> GetProductCategoryAsync(GetProductCategoryInput input)
        {
            if (input.Id == 0)
            {
                throw new UserFriendlyException("خطا در دریافت اطلاعات");
            }

            var pc = _productCategory.GetAll()
                     .SingleOrDefault(p => p.Id == input.Id);

            if (pc == null)
            {
                throw new UserFriendlyException("آیتم مورد نظر وجود ندارد ویا حذف شده است !!!");
            }

            return(new GetProductCategoryOutput()
            {
                PC = new ProductCategoryDto()
                {
                    Id = pc.Id,
                    CreationTime = pc.CreationTime.ToString(),
                    Desc = pc.Description,
                    Name = pc.Name,
                    EnDesc = pc.EnDescription,
                    EnName = pc.EnName
                }
            });
        }
Пример #2
0
        public ListResultDto <ProductCategoryList> GetProductCategory(GetProductCategoryInput input)
        {
            var query = _productCategoryRepository.GetAll()
                        .WhereIf(
                !input.Filter.IsNullOrWhiteSpace(),
                u =>
                u.Code.Contains(input.Filter) ||
                u.Name.Contains(input.Filter) ||
                u.Id.ToString().Contains(input.Filter))
                        .ToList();

            return(new ListResultDto <ProductCategoryList>(query.MapTo <List <ProductCategoryList> >()));
        }