public ActionResult GetRuleDetailByID(int id)
        {
            var oFilterRule = FilterRuleHelper.GetRuleDetailByID(id);

            oFilterRule.OperationTypeMaster = FilterRuleHelper.GetAllOperationType();
            return(View(oFilterRule));
        }
        public ActionResult SampleData(int id, Int64 FeedMappingID, string jsonFileName)
        {
            if (FeedMappingID > 0)
            {
                string contentRootPath = _hostingEnvironment.ContentRootPath;
                var    rootFilePath    = string.Concat(contentRootPath, "/", Settings.FeedJSONFilePath);
                JToken jToken          = null;
                if (!string.IsNullOrEmpty(jsonFileName))
                {
                    dynamic data = null;
                    using (StreamReader r = new StreamReader(Path.Combine(rootFilePath, jsonFileName)))
                    {
                        string json = r.ReadToEnd();
                        data = JsonConvert.DeserializeObject <dynamic>(json);
                    }
                    jToken = data as JToken;
                }

                if (jToken != null)
                {
                    //DbCall getFeed
                    var lstFeedSampleData = new List <FeedSampleData>();
                    var oResult           = MemoryCacheHelper.GetValue("GetSampleData_" + id);
                    if (oResult == null)
                    {
                        lstFeedSampleData = FilterRuleHelper.GetSampleData(id);
                        MemoryCacheHelper.Add("GetSampleData_" + id, lstFeedSampleData, DateTimeOffset.UtcNow.AddHours(1));
                    }
                    else
                    {
                        lstFeedSampleData = oResult as List <FeedSampleData>;
                    }

                    string jsonPath = lstFeedSampleData.FirstOrDefault(x => x.ID == FeedMappingID).ActualFeedKeyPath;
                    if (!string.IsNullOrEmpty(jsonPath))
                    {
                        jsonPath = jsonPath.Substring(jsonPath.LastIndexOf(']') + 1);
                        var jValue = jToken.Root.SelectTokens("$." + jsonPath).FirstOrDefault();
                        if (jValue != null)
                        {
                            var val = jValue.Value <object>();
                            return(Content(
                                       JsonConvert.SerializeObject(val, Formatting.Indented)
                                       , "application/json"));
                        }
                        else
                        {
                            return(Content(JsonConvert.SerializeObject("", Formatting.Indented), "application/json"));
                        }
                    }
                    else
                    {
                        return(Content(
                                   JsonConvert.SerializeObject("", Formatting.Indented)
                                   , "application/json"));
                    }
                }
            }
            return(Json(""));
        }
 //[ValidateInput(false)]
 public ActionResult Create(FilterRule Model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             bool status = FilterRuleHelper.InsertRule(Model);
             if (status)
             {
                 TempData["ResponseMsg"]    = "Rule created succesfully.";
                 TempData["ResponseStatus"] = "success";
             }
             else
             {
                 TempData["ResponseMsg"]    = "Something went wrong.";
                 TempData["ResponseStatus"] = "error";
             }
         }
         else
         {
             ModelState.AddModelError("", "Rule Name Is Required.");
         }
     }
     catch (Exception ex)
     {
         TempData["ResponseStatus"] = false;
         TempData["ResponseMsg"]    = ex.Message;
     }
     return(RedirectToAction("Page", new { id = Model.Id }));
 }
        public ActionResult Create(int id)
        {
            FeedProvider feedProvider = null;
            vmFilterRule rules        = new vmFilterRule();

            feedProvider = FeedProviderHelper.GetFeedProviderDetail(id);

            var FieldNameList = FillFieldName(id);

            ViewBag.FieldNameList = FieldNameList;

            ViewBag.RuleOperator  = FilterRuleHelper.GetALLRuleOperator();
            ViewBag.Operator      = FilterRuleHelper.GetAllOperator();
            ViewBag.OperationType = FilterRuleHelper.GetAllOperationType();
            var lstIntelligentMapping = FeedConfigHelper.GetFeedIntelligentMapping(id);

            if (feedProvider != null)
            {
                Tuple <FeedProvider, vmFilterRule> tuple = new Tuple <FeedProvider, vmFilterRule>(feedProvider, rules);
                return(View(tuple));
            }
            else
            {
                ViewBag.ErrorMessage = "Feed Provider not found";
            }
            return(View());
        }
        public ActionResult Update(int id, bool IsEnable)
        {
            bool   status  = false;
            string message = "";

            status = FilterRuleHelper.UpdateRule(id, IsEnable);

            if (status)
            {
                message = "Record update successfully.";
            }
            else
            {
                message = "Something went wrong. Please try again soon.";
            }

            return(Json(new { status, message }));
        }
        public ActionResult Delete(int id)
        {
            bool   status  = false;
            string message = "";

            status = FilterRuleHelper.DeleteRule(id);

            if (status)
            {
                message = "Record deleted successfully.";
            }
            else
            {
                message = "Something went wrong. Please try again soon.";
            }

            return(Json(new{ status, message }));
        }
        public ActionResult GetAllRuleByFeedID(JQueryDataTableParamModel param, int FeedProviderId)
        {
            var dataTableResponse = new DataTableResponse();

            string search = ""; //It's indicate blank filter

            if (!string.IsNullOrEmpty(param.sSearch))
            {
                search = param.sSearch;
            }

            int offset   = 0;
            int pageSize = param.iDisplayLength;


            if (param.iDisplayStart > 0)
            {
                offset = param.iDisplayStart / pageSize;
            }

            var dataTableRequest = new DataTableRequest();

            dataTableRequest.PageNo    = offset;
            dataTableRequest.PageSize  = pageSize;
            dataTableRequest.Filter    = search.Trim();
            dataTableRequest.SortField = param.iSortCol_0;
            dataTableRequest.SortOrder = param.sSortDir_0;

            dataTableResponse = FilterRuleHelper.GetAllRuleByFeedID(dataTableRequest, FeedProviderId);

            return(Json(new{
                sEcho = param.sEcho,
                iTotalRecords = dataTableResponse.totalNumberofRecord,
                iTotalDisplayRecords = dataTableResponse.filteredRecord,
                aaData = dataTableResponse.data
            }));
        }
        public ActionResult AutoFlush(int FeedProviderID)
        {
            var oResult = FilterRuleHelper.GetAllJsonEventData_V1(FeedProviderID);

            return(Json(oResult));
        }