public ActionResult Index(int?page) { _model.FromDate = DateTime.Now.AddDays(-29); _model.ToDate = DateTime.Now.AddDays(1); _model = _rep.FillModelddl(_model); _model = _rep.GetSearchLogList(_model); return(View(_model)); }
public ActionResult Index(BusSearchLogModel model) { model = _rep.FillModelddl(model); model = _rep.GetSearchLogList(model); return(View(model)); }
public BusSearchLogModel FillModelddl(BusSearchLogModel mdl) { mdl.AgentListddl = AgentListddl(); return(mdl); }
public BusSearchLogModel GetSearchLogList(BusSearchLogModel mdl) { var LogList = _ent.Bus_SearchRequest.Where(x => x.CreatedDate > mdl.FromDate && x.CreatedDate < mdl.ToDate); if (mdl.AgentId != null) { LogList = LogList.Where(y => y.AgentId == mdl.AgentId); } List <BusSearchLogModel> Templst = new List <BusSearchLogModel>(); List <BusSearchLogModel> Reallst = new List <BusSearchLogModel>(); if (LogList != null && LogList.Any()) { foreach (var item in LogList) { BusSearchLogModel model = new BusSearchLogModel { AgentName = item.Agents.AgentName }; Templst.Add(model); } //================== foreach (var tempitm in Templst) { if (Reallst != null && Reallst.Any()) { int count = 0; foreach (var realitm in Reallst) { if (tempitm.AgentName == realitm.AgentName) { count++; } } if (count == 0) { //add new to real list.. var fillitm = Templst.Where(x => x.AgentName == tempitm.AgentName).ToList(); BusSearchLogModel model = new BusSearchLogModel { AgentName = fillitm.FirstOrDefault().AgentName, NoOfSearch = fillitm.Count() }; Reallst.Add(model); } } else { //add new //add new to real list.. var fillitm = Templst.Where(x => x.AgentName == tempitm.AgentName).ToList(); BusSearchLogModel model = new BusSearchLogModel { AgentName = fillitm.FirstOrDefault().AgentName, NoOfSearch = fillitm.Count() }; Reallst.Add(model); } } } //------------------ mdl.SeachList = Reallst; return(mdl); }