public async Task <List <MerchantCategoryDto> > GetAll(MerchantByCategory MerchantByCategory) { int countryID = await _LookupTypeValuesService.GetCountryID(MerchantByCategory.Ipcountry); //return this.Repository.Where(m => m.CategoryID == CategoryID).ToList(); var getMerchantCategory = (from s in this.Repository.Where(m => m.CategoryID == MerchantByCategory.CategoryID) where s.Merchant.Users.Status == 1 where s.Merchant.MerchantRequest.LookupTypeValues.Description == "Approved" select new { s.Merchant, s.MerchantID, s.Merchant.Country, s.Merchant.MerchantRedirection, }).ToList(); List <MerchantCategoryDto> MerchantCategorylist = new List <MerchantCategoryDto>(); foreach (var MerchantCategory in getMerchantCategory) { if (MerchantCategory.Merchant.MerchantSellCountries != null) { foreach (var MerchantSellCategory in MerchantCategory.Merchant.MerchantSellCountries) { if (MerchantSellCategory.Country == countryID) { MerchantCategoryDto MerchantCategoryDto = new MerchantCategoryDto(); MerchantCategoryDto.MerchantID = MerchantCategory.MerchantID; MerchantCategoryDto.MerchantName = MerchantCategory.Merchant.Name; MerchantCategoryDto.MerchantCountry = MerchantCategory.Country; //MerchantCategoryDto.MerchantUrl = MerchantCategory.Merchant.Website; MerchantCategoryDto.MerchantWebImage = MerchantCategory.Merchant.CompanyImage; MerchantCategoryDto.MerchantProfileImage = MerchantCategory.Merchant.ProfileImage; string Merchantatt = ""; if (MerchantCategory.MerchantRedirection.Count > 0) { foreach (var MerchantRedirection in MerchantCategory.MerchantRedirection) { Merchantatt += "&" + MerchantRedirection.Attribute + "=" + MerchantRedirection.Value; } } if (Merchantatt != "" && MerchantCategory.Merchant.MerchantRedirectionUrl != "") { MerchantCategoryDto.MerchantUrl = MerchantCategory.Merchant.MerchantRedirectionUrl + "?MerchantID=" + MerchantCategory.MerchantID + Merchantatt; } if (Merchantatt == "" && MerchantCategory.Merchant.MerchantRedirectionUrl != "") { MerchantCategoryDto.MerchantUrl = MerchantCategory.Merchant.MerchantRedirectionUrl; } MerchantCategorylist.Add(MerchantCategoryDto); } } } } return(MerchantCategorylist); }
public async Task <IActionResult> GetMerchantCategory(MerchantByCategory MerchantByCategory) { try { strMerchantImages = _configuration["FilePath:ImagePath"] + "MerchantImages/"; string strServerURL = _configuration["FilePath:ServerURL"] + "MerchantImages/"; var _GetMerchantCategory = await _MerchantCategoryService.GetAll(MerchantByCategory); if (_GetMerchantCategory.Count > 0) { for (int i = 0; i < _GetMerchantCategory.Count(); i++) { if (System.IO.File.Exists(strMerchantImages + _GetMerchantCategory[i].MerchantProfileImage)) { _GetMerchantCategory[i].MerchantProfileImage = strServerURL + _GetMerchantCategory[i].MerchantProfileImage; } else { _GetMerchantCategory[i].MerchantProfileImage = ""; } if (System.IO.File.Exists(strMerchantImages + _GetMerchantCategory[i].MerchantWebImage)) { _GetMerchantCategory[i].MerchantWebImage = strServerURL + _GetMerchantCategory[i].MerchantWebImage; } else { _GetMerchantCategory[i].MerchantWebImage = strServerURL + "CategoryImagesDummy.jpg"; } //if (!string.IsNullOrEmpty(_GetMerchantCategory[i].MerchantUrl)) //{ // var _getMerchantRedirectionlist = await _MerchantRedirectionService.getMerchantRedirectionlist(_GetMerchantCategory[i].MerchantID); // string Merchantatt = ""; // if (!string.IsNullOrEmpty(_getMerchantRedirectionlist.MerchantRedirectionUrl)) // { // foreach (var MerchantRedirection in _getMerchantRedirectionlist.MerchantRedirectionUrl) // { // Merchantatt += "&" + MerchantRedirection.MerchantAttribute + "=" + MerchantRedirection.MerchantValue; // } // } // if (Merchantatt != "") // { // _GetMerchantCategory[i].MerchantUrl = _GetMerchantCategory[i].MerchantUrl + "?MerchantID=" + _GetMerchantCategory[i].MerchantID + Merchantatt; // } //} } return(Ok(_GetMerchantCategory)); } else { return(Ok(_GetMerchantCategory)); } } catch (Exception err) { return(BadRequest(new GenericResultDto <string> { Result = err.Message })); } }