public async Task <IActionResult> Get(GetCategoryDto GetCategoryDto)
        {
            try
            {
                var _getAllCategories = await _CategoryService.GetAll(GetCategoryDto);

                strImagePath = _configuration["FilePath:ImagePath"] + "CategoryImages/";
                string strServerURL = _configuration["FilePath:ServerURL"] + "CategoryImages/";
                foreach (var returnlist in _getAllCategories)
                {
                    if (System.IO.File.Exists(strImagePath + returnlist.Image))
                    {
                        returnlist.Image = strServerURL + returnlist.Image;
                    }
                    else
                    {
                        returnlist.Image = strServerURL + "CategoryImagesDummy.jpg";
                    }
                }

                return(Ok(_getAllCategories));
            }
            catch (Exception err)
            {
                return(BadRequest(new GenericResultDto <string> {
                    Result = err.Message
                }));
            }
        }
Пример #2
0
        public async Task <GetCategoryDto> Get(string type)
        {
            var category = await _context.Categories
                           .FirstOrDefaultAsync(c => c.Type == type);

            if (category == null)
            {
                // Exception handler
                return(null);
            }

            var categoryDto = new GetCategoryDto {
                Id = category.Id, Type = category.Type
            };

            return(categoryDto);
        }
Пример #3
0
        public async Task <ActionResult> GetCategory([FromBody] GetCategoryDto viewRequest)
        {
            if (!TryValidateModel(viewRequest))
            {
                return(BadRequest(ValidationHelper.GetModelErrors(ModelState)));
            }

            var request = this._mapper.Map <GetCategoryRequest>(viewRequest);

            request.UserName = HttpContext.User.Identity.Name;
            var command = new GetCategoryCommand
            {
                Data = request
            };

            return(await Go(command));
        }
        public async Task <List <GetCategorylistDto> > GetAll(GetCategoryDto GetCategoryDto)
        {
            List <GetCategorylistDto> Categorylist = new List <GetCategorylistDto>();
            //return Repository.OrderBy(x => x.Priority).ToList();
            int countryID = await _LookupTypeValuesService.GetCountryID(GetCategoryDto.Ipcountry);

            var getCategory = (from s in this.Repository
                               select new
            {
                s.Id,
                s.Image,
                s.Name,
                s.Priority,
                s.IsActive,
                //s.MerchantCategory
            }).ToList();

            if (GetCategoryDto.Type != "A")
            {
                getCategory = getCategory.Where(m => m.IsActive.Equals(1)).ToList()
                              .OrderBy(x => x.Priority).ToList();
                foreach (var Category in getCategory)
                {
                    int Merchantcount = 0;
                    GetCategorylistDto CategoryDto = new GetCategorylistDto();

                    CategoryDto.Id       = Category.Id;
                    CategoryDto.Image    = Category.Image;
                    CategoryDto.Name     = Category.Name;
                    CategoryDto.Priority = Category.Priority;
                    CategoryDto.IsActive = Category.IsActive;
                    //foreach (var MerchantCategory in Category.MerchantCategory)
                    //{
                    //    if (MerchantCategory.Merchant != null && MerchantCategory.Merchant.MerchantSellCountries != null)
                    //    {
                    //        foreach (var MerchantSellCategory in MerchantCategory.Merchant.MerchantSellCountries)
                    //        {
                    //            if (MerchantSellCategory.Country == countryID)
                    //            {
                    //                if (MerchantCategory.Merchant.MerchantRequest != null)
                    //                {
                    //                    if (MerchantCategory.Merchant.MerchantRequest.ApprovalStatus != 0)
                    //                    {
                    //                        if (MerchantCategory.Merchant.MerchantRequest.ApprovalStatus == 26)
                    //                        {
                    //                            Merchantcount++;
                    //                        }
                    //                    }
                    //                }
                    //            }
                    //        }
                    //    }
                    //}
                    CategoryDto.MerchantCount = Merchantcount;
                    Categorylist.Add(CategoryDto);
                }
            }
            else
            {
                foreach (var Category in getCategory)
                {
                    GetCategorylistDto CategoryDto = new GetCategorylistDto();

                    CategoryDto.Id       = Category.Id;
                    CategoryDto.Image    = Category.Image;
                    CategoryDto.Name     = Category.Name;
                    CategoryDto.Priority = Category.Priority;
                    CategoryDto.IsActive = Category.IsActive;
                    Categorylist.Add(CategoryDto);
                }
            }

            return(Categorylist.OrderBy(x => x.Priority).ToList());
        }