public ActionResult List() { ListViewModel model = new ListViewModel(); model.Filter = new ListFilterViewModel(); model.CurrentPage = 1; model.PageSize = 10; ProfileSearchFilter searchFilter = new ProfileSearchFilter(); searchFilter.CurrentPage = model.CurrentPage.HasValue ? model.CurrentPage.Value : 1; searchFilter.PageSize = model.PageSize.HasValue ? model.PageSize.Value : 10; searchFilter.SortOn = model.SortOn; searchFilter.SortDirection = model.SortDirection; searchFilter.Filter_Code = model.Filter.Filter_Code; searchFilter.Filter_Name = model.Filter.Filter_Name; try { model.DataList = _profileService.GetAllPaginatedWithDetailBySearchFilter(searchFilter); } catch { model.DataList = new PaginatedList <Profile>(new List <Profile>(), 0, searchFilter.CurrentPage, searchFilter.PageSize, searchFilter.SortOn, searchFilter.SortDirection); ViewBag.ErrorMessage = "Error"; } return(View(model)); }
public ActionResult List() { ListViewModel model = new ListViewModel(); model.Filter = new ListFilterViewModel(); model.CurrentPage = 1; model.PageSize = 10; ProfileSearchFilter searchFilter = new ProfileSearchFilter(); searchFilter.CurrentPage = model.CurrentPage.HasValue ? model.CurrentPage.Value : 1; searchFilter.PageSize = model.PageSize.HasValue ? model.PageSize.Value : 10; searchFilter.SortOn = model.SortOn; searchFilter.SortDirection = model.SortDirection; searchFilter.Filter_Code = model.Filter.Filter_Code; searchFilter.Filter_NameTR = model.Filter.Filter_NameTR; searchFilter.Filter_NameEN = model.Filter.Filter_NameEN; var apiResponseModel = _profileService.GetAllPaginatedWithDetailBySearchFilter(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, searchFilter); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { model.DataList = apiResponseModel.Data; } else { ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage; ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList; return(View(model)); } return(View(model)); }
public ActionResult List(ListViewModel model) { // filter bilgilerinin default boş değerlerle doldurulması sağlanıyor if (model.Filter == null) { model.Filter = new ListFilterViewModel(); } if (!model.CurrentPage.HasValue) { model.CurrentPage = 1; } if (!model.PageSize.HasValue) { model.PageSize = 10; } ProfileSearchFilter searchFilter = new ProfileSearchFilter(); searchFilter.CurrentPage = model.CurrentPage.HasValue ? model.CurrentPage.Value : 1; searchFilter.PageSize = model.PageSize.HasValue ? model.PageSize.Value : 10; searchFilter.SortOn = model.SortOn; searchFilter.SortDirection = model.SortDirection; searchFilter.Filter_Code = model.Filter.Filter_Code; searchFilter.Filter_Name = model.Filter.Filter_Name; model.DataList = _profileService.GetAllPaginatedWithDetailBySearchFilter(searchFilter); return(View(model)); }
public PaginatedList <Profile> GetAllPaginatedWithDetailBySearchFilter(ProfileSearchFilter searchFilter) { PaginatedList <Profile> resultList = new PaginatedList <Profile>(new List <Profile>(), 0, searchFilter.CurrentPage, searchFilter.PageSize, searchFilter.SortOn, searchFilter.SortDirection); using (AppDBContext dbContext = new AppDBContext(_config)) { var query = from p in dbContext.Profile where p.IsDeleted == false select p; // filtering if (!string.IsNullOrEmpty(searchFilter.Filter_Code)) { query = query.Where(r => r.Code.Contains(searchFilter.Filter_Code)); } if (!string.IsNullOrEmpty(searchFilter.Filter_Name)) { query = query.Where(r => r.Name.Contains(searchFilter.Filter_Name)); } // asnotracking query = query.AsNoTracking(); //total count var totalCount = query.Count(); //sorting if (!string.IsNullOrEmpty(searchFilter.SortOn)) { // using System.Linq.Dynamic.Core; nuget paketi ve namespace eklenmelidir, dynamic order by yapmak icindir query = query.OrderBy(searchFilter.SortOn + " " + searchFilter.SortDirection.ToUpper()); } else { // deefault sıralama vermek gerekiyor yoksa skip metodu hata veriyor ef 6'da -- 28.10.2019 15:40 // https://stackoverflow.com/questions/3437178/the-method-skip-is-only-supported-for-sorted-input-in-linq-to-entities query = query.OrderBy(r => r.Id); } //paging query = query.Skip((searchFilter.CurrentPage - 1) * searchFilter.PageSize).Take(searchFilter.PageSize); resultList = new PaginatedList <Profile>( query.ToList(), totalCount, searchFilter.CurrentPage, searchFilter.PageSize, searchFilter.SortOn, searchFilter.SortDirection ); } return(resultList); }
public ActionResult List() { ListViewModel model = new ListViewModel(); model.Filter = new ListFilterViewModel(); model.CurrentPage = 1; model.PageSize = 10; ProfileSearchFilter searchFilter = new ProfileSearchFilter(); searchFilter.CurrentPage = model.CurrentPage.HasValue ? model.CurrentPage.Value : 1; searchFilter.PageSize = model.PageSize.HasValue ? model.PageSize.Value : 10; searchFilter.SortOn = model.SortOn; searchFilter.SortDirection = model.SortDirection; searchFilter.Filter_Code = model.Filter.Filter_Code; searchFilter.Filter_Name = model.Filter.Filter_Name; model.DataList = _profileService.GetAllPaginatedWithDetailBySearchFilter(searchFilter); return(View(model)); }
public ActionResult List(ListViewModel model) { // filter bilgilerinin default boş değerlerle doldurulması sağlanıyor if (model.Filter == null) { model.Filter = new ListFilterViewModel(); } if (!model.CurrentPage.HasValue) { model.CurrentPage = 1; } if (!model.PageSize.HasValue) { model.PageSize = 10; } ProfileSearchFilter searchFilter = new ProfileSearchFilter(); searchFilter.CurrentPage = model.CurrentPage.HasValue ? model.CurrentPage.Value : 1; searchFilter.PageSize = model.PageSize.HasValue ? model.PageSize.Value : 10; searchFilter.SortOn = model.SortOn; searchFilter.SortDirection = model.SortDirection; searchFilter.Filter_Code = model.Filter.Filter_Code; searchFilter.Filter_NameTR = model.Filter.Filter_NameTR; searchFilter.Filter_NameEN = model.Filter.Filter_NameEN; model.CurrentLanguageTwoChar = SessionHelper.CurrentLanguageTwoChar; var apiResponseModel = _profileService.GetAllPaginatedWithDetailBySearchFilter(SessionHelper.CurrentUser.UserToken, SessionHelper.CurrentLanguageTwoChar, searchFilter); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { model.DataList = apiResponseModel.Data; } else { ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage; ViewBag.ErrorMessageList = apiResponseModel.ErrorMessageList; return(View(model)); } return(View(model)); }
public ActionResult List(ListViewModel model) { if (model.Filter == null) { model.Filter = new ListFilterViewModel(); } if (!model.CurrentPage.HasValue) { model.CurrentPage = 1; } if (!model.PageSize.HasValue) { model.PageSize = 10; } ProfileSearchFilter searchFilter = new ProfileSearchFilter(); searchFilter.CurrentPage = model.CurrentPage.HasValue ? model.CurrentPage.Value : 1; searchFilter.PageSize = model.PageSize.HasValue ? model.PageSize.Value : 10; searchFilter.SortOn = model.SortOn; searchFilter.SortDirection = model.SortDirection; searchFilter.Filter_Code = model.Filter.Filter_Code; searchFilter.Filter_Name = model.Filter.Filter_Name; var apiResponseModel = _profileService.GetAllPaginatedWithDetailBySearchFilter(SessionHelper.CurrentUser.UserToken, searchFilter); if (apiResponseModel.ResultStatusCode == ResultStatusCodeStatic.Success) { model.DataList = apiResponseModel.Data; } else { ViewBag.ErrorMessage = apiResponseModel.ResultStatusMessage; model.DataList = new Business.Models.PaginatedList <Profile>(new List <Profile>(), 0, model.CurrentPage.Value, model.PageSize.Value, model.SortOn, model.SortDirection); return(View(model)); } // select lists return(View(model)); }
public ApiResponseModel <PaginatedList <Profile> > GetAllPaginatedWithDetailBySearchFilter(string userToken, ProfileSearchFilter searchFilter) { ApiResponseModel <PaginatedList <Profile> > result = new ApiResponseModel <PaginatedList <Profile> >() { Data = new PaginatedList <Profile>(new List <Profile>(), 0, searchFilter.CurrentPage, searchFilter.PageSize, searchFilter.SortOn, searchFilter.SortDirection) }; using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken); var portalApiRequestModel = new GetAllPaginatedRequestModel(); portalApiRequestModel.UserToken = userToken; portalApiRequestModel.CurrentPage = searchFilter.CurrentPage; portalApiRequestModel.PageSize = searchFilter.PageSize; portalApiRequestModel.SortOn = searchFilter.SortOn; portalApiRequestModel.SortDirection = searchFilter.SortDirection; ListFilterRequestModel listFilter = new ListFilterRequestModel(); listFilter.Filter_Code = searchFilter.Filter_Code; listFilter.Filter_Name = searchFilter.Filter_Name; portalApiRequestModel.Filter = listFilter; HttpResponseMessage response = httpClient.PostAsJsonAsync(string.Format("Profile/GetAllPaginatedWithDetail"), portalApiRequestModel).Result; result = response.Content.ReadAsAsync <ApiResponseModel <PaginatedList <Profile> > >().Result; } return(result); }
//api ile bağlandıgımız servisler public ApiResponseModel <PaginatedList <Profile> > GetAllPaginatedWithDetailBySearchFilter(string userToken, string displayLanguage, ProfileSearchFilter searchFilter) { ApiResponseModel <PaginatedList <Profile> > result = new ApiResponseModel <PaginatedList <Profile> >() { Data = new PaginatedList <Profile>(new List <Profile>(), 0, searchFilter.CurrentPage, searchFilter.PageSize, searchFilter.SortOn, searchFilter.SortDirection) }; //portal api'den çekme işlemi using (HttpClient httpClient = new HttpClient()) { httpClient.BaseAddress = new Uri(ConfigHelper.ApiUrl); httpClient.DefaultRequestHeaders.Accept.Clear(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", userToken); httpClient.DefaultRequestHeaders.Add("DisplayLanguage", displayLanguage); HttpResponseMessage response = httpClient.GetAsync(string.Format("v1/Profile?CurrentPage={0}&PageSize={1}&SortOn={2}&SortDirection={3}&Code={4}&Name={5}", searchFilter.CurrentPage, searchFilter.PageSize, searchFilter.SortOn, searchFilter.SortDirection, searchFilter.Filter_Code, searchFilter.Filter_Name)).Result; result = response.Content.ReadAsJsonAsync <ApiResponseModel <PaginatedList <Profile> > >().Result; } return(result); }