public List <Actor> GetAllActors() { string connectionString = Utility.Util.GetConnectionString(MoviesStore.Service.Common.Util.MasterDataManager.ConfigData["MoviesStoreDb"]); string providerName = Utility.Util.GetProviderName(MoviesStore.Service.Common.Util.MasterDataManager.ConfigData["MoviesStoreDb"]); string spName = MoviesStore.Service.Common.Util.MasterDataManager.ConfigData["GetAllActors"]; try { return(_actorRepository.GetAllActors(spName, providerName, connectionString)); } catch (Exception e) { throw e.InnerException; } }
public IActionResult Index(string sortColumn, string sortOrder, string page, string pageSize) { var pageSizeConverted = 0; if (string.IsNullOrEmpty(pageSize)) { if (string.IsNullOrEmpty(HttpContext.Session.GetString("pageSize"))) { pageSizeConverted = 50; HttpContext.Session.SetString("pageSize", pageSizeConverted.ToString()); } else { pageSizeConverted = Convert.ToInt32(HttpContext.Session.GetString("pageSize")); } //pageSizeConverted = 50; } else { HttpContext.Session.SetString("pageSize", pageSize.ToString()); pageSizeConverted = Convert.ToInt32(pageSize); } var actonListViewModel = new ActorsListViewModel(); var items = _repository.GetAllActors().Select(actor => new ActorItemViewModel { ActorId = actor.ActorId, FirstName = actor.FirstName, LastName = actor.LastName }); items = _sortingLogic.SortActorList(ref sortColumn, ref sortOrder, items); var pageCount = (double)items.Count() / pageSizeConverted; int currentPage = string.IsNullOrEmpty(page) ? 1 : Convert.ToInt32(page); items = items.Skip((currentPage - 1) * pageSizeConverted).Take(pageSizeConverted); actonListViewModel.PagingViewModel.MaxPages = (int)Math.Ceiling(pageCount); actonListViewModel.PagingViewModel.CurrentPage = currentPage; actonListViewModel.PagingViewModel.pageSize = pageSizeConverted.ToString(); actonListViewModel.Items = items.ToList(); actonListViewModel.SortColumn = sortColumn; actonListViewModel.SortOrder = sortOrder; return(View(actonListViewModel)); }
public async Task <ActionResult <IList <ActorDTO> > > GetAllActors() { try { var result = await _actorRepository.GetAllActors(); var mappedResults = _mapper.Map <IList <ActorDTO> >(result).Select(a => HateoasMainLinks(a)); if (result.Count == 0) { return(NotFound(result)); } return(Ok(mappedResults)); } catch (Exception e) { return(this.StatusCode(StatusCodes.Status500InternalServerError, $"Database failure: {e.Message}")); } }
public IEnumerable <Actor> GetAllActors() { var result = _actorRepository.GetAllActors(); return(result); }