public IActionResult Get(string firstLetter, [FromQuery] ApiParams apiParams) { var model = _service.GetCodes(firstLetter, apiParams); return(Ok(model)); }
public JsonResult Codes_Read(int?pageSize, int?pageNumber, string sort) { GeneralResponse response = new GeneralResponse(); #region Access Check bool hasPermission = GetEmployee().IsGuaranteed("Code_Read"); if (!hasPermission) { ModelState.AddModelError("", "AccessDenied"); return(Json(response, JsonRequestBehavior.AllowGet)); } #endregion int PageNumber = pageNumber == null ? -1 : (int)pageNumber; int PageSize = pageSize == null ? -1 : (int)pageSize; response = _codeService.GetCodes(PageSize, PageNumber, ConvertJsonToObject(sort)); return(Json(response, JsonRequestBehavior.AllowGet)); }
public ActionResult List(DataSourceRequest command, string searchValues, IEnumerable <Sort> sort = null) { var model = _httpContext.Session[SessionKey.CodeSearchModel] as SearchModel; if (model == null) { model = BuildSearchModel(); } else { model.ClearValues(); } //validate var errorFilters = model.Validate(searchValues); foreach (var filter in errorFilters) { ModelState.AddModelError(filter.Name, _localizationService.GetResource(filter.ResourceKey + ".Required")); } if (ModelState.IsValid) { //session update model.Update(searchValues); _httpContext.Session[SessionKey.CodeSearchModel] = model; PagedResult <Code> data = _codeService.GetCodes(model.ToExpression(), model.ToParameters(), command.Page - 1, command.PageSize, sort); var gridModel = new DataSourceResult { Data = data.Result.Select(x => x.ToModel()), Total = data.TotalCount }; return(new JsonResult { Data = gridModel }); } return(Json(new { Errors = ModelState.SerializeErrors() })); }
public IActionResult Get([FromQuery] ApiParams apiParams) { var model = _service.GetCodes(apiParams); return(Ok(model)); }
public ActionResult CheckDomain(string domain = "http://localhost:55283/", string code = "1257d6da-f300-4b18-aa76-fedcaa9655b1") { var serverIP = "http://172.16.10.115:9006"; var titleLength = 40; var contentLength = 90; if (domain != "" && code != "") { var queryResult = _codeService.GetCodes().Where(c => domain.Contains(c.Domain.Name) && c.Value == code); if (queryResult != null) { var codeResult = queryResult.FirstOrDefault(); var listMaterial = new List <Material>(); foreach (var item in _adMaterialMappingService.GetAdMaterialMappings().Where(amm => amm.AdId == codeResult.AdId).ToList()) { listMaterial.Add(item.Material); } var firstAd = 0; var secondAd = 0; var thirdAd = 0; var fourthAd = 0; switch (codeResult.Ad.Name) { case "Banner_Bottom_Right": case "Banner_Bottom_Left": case "Banner_Column_Right": secondAd = firstAd = rand.Next(0, listMaterial.Count()); while (secondAd == firstAd) { secondAd = rand.Next(0, listMaterial.Count()); } return(Json(new { message = "success", link_1 = listMaterial[firstAd].Link, image_1 = listMaterial[firstAd].Image, title_1 = slitString.TruncateAtWord(listMaterial[firstAd].Title, titleLength), url_1 = listMaterial[firstAd].Url, content_1 = slitString.TruncateAtWord(listMaterial[firstAd].Content, contentLength), price_1 = listMaterial[firstAd].Price.ToString("N0"), price_type_1 = listMaterial[firstAd].PriceType, link_2 = listMaterial[secondAd].Link, image_2 = listMaterial[secondAd].Image, title_2 = slitString.TruncateAtWord(listMaterial[secondAd].Title, titleLength), url_2 = listMaterial[secondAd].Url, content_2 = slitString.TruncateAtWord(listMaterial[secondAd].Content, contentLength), price_2 = listMaterial[secondAd].Price.ToString("N0"), price_type_2 = listMaterial[secondAd].PriceType, code = code, script = codeResult.Ad.Script, func = codeResult.Ad.Func })); case "Banner_Top_Left": case "Banner_Top_Right": case "Banner_Bottom_Center": case "Banner_Column_Right_Big": thirdAd = secondAd = firstAd = rand.Next(0, listMaterial.Count()); while (secondAd == firstAd) { secondAd = rand.Next(0, listMaterial.Count()); } while (thirdAd == secondAd || thirdAd == firstAd) { thirdAd = rand.Next(0, listMaterial.Count()); } return(Json(new { message = "success", link_1 = listMaterial[firstAd].Link, image_1 = listMaterial[firstAd].Image, title_1 = slitString.TruncateAtWord(listMaterial[firstAd].Title, titleLength), url_1 = listMaterial[firstAd].Url, content_1 = slitString.TruncateAtWord(listMaterial[firstAd].Content, contentLength), price_1 = listMaterial[firstAd].Price.ToString("N0"), price_type_1 = listMaterial[firstAd].PriceType, link_2 = listMaterial[secondAd].Link, image_2 = listMaterial[secondAd].Image, title_2 = slitString.TruncateAtWord(listMaterial[secondAd].Title, titleLength), url_2 = listMaterial[secondAd].Url, content_2 = slitString.TruncateAtWord(listMaterial[secondAd].Content, contentLength), price_2 = listMaterial[secondAd].Price.ToString("N0"), price_type_2 = listMaterial[secondAd].PriceType, link_3 = listMaterial[thirdAd].Link, image_3 = listMaterial[thirdAd].Image, title_3 = slitString.TruncateAtWord(listMaterial[thirdAd].Title, titleLength), url_3 = listMaterial[thirdAd].Url, content_3 = slitString.TruncateAtWord(listMaterial[thirdAd].Content, contentLength), price_3 = listMaterial[thirdAd].Price.ToString("N0"), price_type_3 = listMaterial[thirdAd].PriceType, code = code, script = codeResult.Ad.Script, func = codeResult.Ad.Func })); case "Banner_Inside": fourthAd = thirdAd = secondAd = firstAd = rand.Next(0, listMaterial.Count()); while (secondAd == firstAd) { secondAd = rand.Next(0, listMaterial.Count()); } while (thirdAd == secondAd || thirdAd == firstAd) { thirdAd = rand.Next(0, listMaterial.Count()); } while (fourthAd == secondAd || fourthAd == firstAd || fourthAd == thirdAd) { fourthAd = rand.Next(0, listMaterial.Count()); } return(Json(new { message = "success", link_1 = listMaterial[firstAd].Link, image_1 = listMaterial[firstAd].Image, title_1 = slitString.TruncateAtWord(listMaterial[firstAd].Title, titleLength), url_1 = listMaterial[firstAd].Url, content_1 = slitString.TruncateAtWord(listMaterial[firstAd].Content, contentLength), price_1 = listMaterial[firstAd].Price.ToString("N0"), price_type_1 = listMaterial[firstAd].PriceType, link_2 = listMaterial[secondAd].Link, image_2 = listMaterial[secondAd].Image, title_2 = slitString.TruncateAtWord(listMaterial[secondAd].Title, titleLength), url_2 = listMaterial[secondAd].Url, content_2 = slitString.TruncateAtWord(listMaterial[secondAd].Content, contentLength), price_2 = listMaterial[secondAd].Price.ToString("N0"), price_type_2 = listMaterial[secondAd].PriceType, link_3 = listMaterial[thirdAd].Link, image_3 = listMaterial[thirdAd].Image, title_3 = slitString.TruncateAtWord(listMaterial[thirdAd].Title, titleLength), url_3 = listMaterial[thirdAd].Url, content_3 = slitString.TruncateAtWord(listMaterial[thirdAd].Content, contentLength), price_3 = listMaterial[thirdAd].Price.ToString("N0"), price_type_3 = listMaterial[thirdAd].PriceType, link_4 = listMaterial[fourthAd].Link, image_4 = listMaterial[fourthAd].Image, title_4 = slitString.TruncateAtWord(listMaterial[fourthAd].Title, titleLength), url_4 = listMaterial[fourthAd].Url, content_4 = slitString.TruncateAtWord(listMaterial[fourthAd].Content, contentLength), price_4 = listMaterial[fourthAd].Price.ToString("N0"), price_type_4 = listMaterial[fourthAd].PriceType, code = code, script = codeResult.Ad.Script, func = codeResult.Ad.Func })); case "Video_Column_Right": case "Video_Bottom_Right": case "Video_Bottom_Left": case "Video_Top_Right": case "Video_Top_Left": case "Video_Middle_Right": case "Video_Middle_Left": case "Video_Inside": firstAd = rand.Next(0, listMaterial.Count()); return(Json(new { message = "success", link_1 = listMaterial[firstAd].Link, image_1 = listMaterial[firstAd].Image, video_1 = serverIP + listMaterial[firstAd].Video, code = code, script = codeResult.Ad.Script, func = codeResult.Ad.Func })); case "Gif_Top_Left": case "Gif_Top_Right": case "Gif_Column_Right": case "Gif_Top_Center": case "Gif_Inside": case "Gif_Bottom_Center": case "Gif_Bottom_Left": case "Gif_Bottom_Right": case "Gif_Column_Right_Square": firstAd = rand.Next(0, listMaterial.Count()); return(Json(new { message = "success", link_1 = listMaterial[firstAd].Link, image_1 = serverIP + listMaterial[firstAd].Image, code = code, script = codeResult.Ad.Script, func = codeResult.Ad.Func })); } } } return(Json(new { message = "error" })); }