public ActionResult ConfigurateParameterDownload(Category_ZipCode parameter) { return Json(true, JsonRequestBehavior.AllowGet); }
public ActionResult GetInfo(FactualDownloadParameter parameter) { List<BusinessCategoryViewModel> listReturn = new List<BusinessCategoryViewModel>(); if (parameter != null) { //get zip code of county var zipcodes = zipcodeService.Get() .Where(c => c.City.Equals(parameter.City) && c.Country.Equals(parameter.Country) && c.State.Equals(parameter.State)) .ToList(); //get categoryL1 BusinessCategory CategoryL1; BusinessCategory CategoryL2; BusinessCategory CategoryL3; BusinessCategory CategoryL4; BusinessCategory MainCategory = new BusinessCategory(); ArrayList category_ids = new ArrayList(); if (parameter.CategoryL1 != null) { CategoryL1 = businessCategoryService.Get(parameter.CategoryL1); MainCategory = CategoryL1; if (MainCategory != null) { category_ids.Add(MainCategory.CategoryId); } } if (parameter.CategoryL2 != null && parameter.CategoryL2 != Guid.Empty) { CategoryL2 = businessCategoryService.Get(parameter.CategoryL2); MainCategory = CategoryL2; if (MainCategory != null) { category_ids.Add(MainCategory.CategoryId); } } if (parameter.CategoryL3 != null && parameter.CategoryL3 != Guid.Empty) { CategoryL3 = businessCategoryService.Get(parameter.CategoryL3); MainCategory = CategoryL3; if (MainCategory != null) { category_ids.Add(MainCategory.CategoryId); } } if (parameter.CategoryL4 != null && parameter.CategoryL4 != Guid.Empty) { CategoryL4 = businessCategoryService.Get(parameter.CategoryL4); MainCategory = CategoryL4; if (MainCategory != null) { category_ids.Add(MainCategory.CategoryId); } } string categoryIDs = string.Join(",", category_ids.ToArray()); if (MainCategory != null && MainCategory.Id != Guid.Empty) { foreach (var zip in zipcodes) { //insert new Category_ZipCode cate = new Category_ZipCode(); cate.Id = Guid.NewGuid(); cate.BusinessCategoryId = MainCategory.Id; cate.ZipcodeId = zip.Id; cate.ZipcodeName = zip.Zip; cate.TotalRecord = 0; cate.Downloaded = 0; cate.CategoryName = MainCategory.Name; cate.CategoryId = MainCategory.CategoryId; var cate_zip = category_ZipCodeService.Get().FirstOrDefault(c => c.BusinessCategoryId == MainCategory.Id && c.ZipcodeName == zip.Zip); if (cate_zip == null) { category_ZipCodeService.Add(cate); } //convert to businesCategory View model BusinessCategoryViewModel model = new BusinessCategoryViewModel(); model.Category_ZipId = cate.Id; model.Zipcode = zip.Zip; model.TotalDownloaded = cate_zip == null ? 0 : cate_zip.Downloaded; model.State = zip.State; model.City = zip.City; model.Availble = cate_zip == null ? 0 : cate_zip.TotalRecord; model.IsChoose = false; model.CategoryInclude = categoryIDs; listReturn.Add(model); } } } return Json(listReturn, JsonRequestBehavior.AllowGet); }
public List<BusinessCategoryViewModel> GetDownloadInfo(string country, string state, string city, int categoryId) { List<BusinessCategoryViewModel> result = new List<BusinessCategoryViewModel>(); var zipcodes = zipcodeService.Get() .Where(c => c.City.Equals(city) && c.Country.Equals(country) && c.State.Equals(state)) .ToList(); var businessCategory = businessCategoryService.GetByFactualCategoryId(categoryId); if (businessCategory != null) { foreach (var zip in zipcodes) { //insert new var businessCategoryId = businessCategory.Id; Category_ZipCode cate = new Category_ZipCode(); cate.Id = Guid.NewGuid(); cate.BusinessCategoryId = businessCategoryId; cate.ZipcodeId = zip.Id; cate.ZipcodeName = zip.Zip; cate.TotalRecord = 0; cate.Downloaded = 0; cate.CategoryName = businessCategory.Name; cate.CategoryId = categoryId; var cate_zip = category_ZipCodeService.Get().FirstOrDefault(c => c.BusinessCategoryId == businessCategoryId && c.ZipcodeName == zip.Zip); if (cate_zip == null) { category_ZipCodeService.Add(cate); } //convert to businesCategory View model BusinessCategoryViewModel model = new BusinessCategoryViewModel(); model.Category_ZipId = cate.Id; model.Zipcode = zip.Zip; model.TotalDownloaded = cate_zip == null ? 0 : cate_zip.Downloaded; model.State = zip.State; model.City = zip.City; model.Availble = cate_zip == null ? 0 : cate_zip.TotalRecord; result.Add(model); } } return result; }