/// <summary> /// Used to get list of System dropdown /// </summary> /// <returns></returns> public List <TrendDropDowdModel> GetSystemList() { List <TrendDropDowdModel> objSystemList = new List <TrendDropDowdModel>(); var unitOfWork = new UnitOfWork <CarMDEntities>(); var userRepo = unitOfWork.GetRepository <User>(); // Apply limit for get records 500. Remove it once in future. var query = (from user in userRepo.DoQuery() select new TrendDropDowdModel { Value = user.FirstName + " " + user.LastName, Id = user.UserTypeExternalId }).Distinct().Take(500).ToList(); var systemList = query.GroupBy(x => x.Id).Select(y => y.FirstOrDefault()).ToList(); foreach (var rowData in systemList) { TrendDropDowdModel objRow = new TrendDropDowdModel() { Id = rowData.Id, Value = rowData.Value }; objSystemList.Add(objRow); } return(objSystemList); }
/// <summary> /// Used to bind the system dropdown /// </summary> /// <returns></returns> public ActionResult GetSystemList() { try { var token = objToken.GetAPIToken(); HttpResponseMessage httpResponse = API.Get.APIRequestAll("Reports/GetSystemList", token); string response = httpResponse.Content.ReadAsStringAsync().Result; List <TrendDropDowdModel> system = JsonConvert.DeserializeObject <List <TrendDropDowdModel> >(response); TrendDropDowdModel model = new TrendDropDowdModel(); model.Value = "No Selection"; model.Id = ""; List <TrendDropDowdModel> list = new List <TrendDropDowdModel>(); list.Add(model); list.AddRange(system); return(Json(list, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("", JsonRequestBehavior.AllowGet)); } }