/// <summary> /// Searches the shareholder. /// </summary> /// <param name="model">The model.</param> /// <returns></returns> public async Task <List <ShareholderSearchViewModel> > SearchShareholder(ShareholderSearchModel model) { const string defaultSort = "Name ASC"; var sortType = model.IsSortDesc ? "DESC" : "ASC"; var sortField = ValidateUtils.IsNullOrEmpty(model.SortField) ? defaultSort : $"{model.SortField} {sortType}"; var query = _userProfileRepository.GetManyAsNoTracking(x => (ValidateUtils.IsNullOrEmpty(model.Name) || x.FirstName.ToUpper().Contains(model.Name.ToUpper())) && (ValidateUtils.IsNullOrEmpty(model.Name) || x.LastName.ToUpper().Contains(model.Name.ToUpper()))) .Select(x => new { x.UserProfileId, name = $"{x.FirstName} {x.LastName}", x.Email }) .Join(_shareholderRepository.GetAllAsNoTracking(), x => x.UserProfileId, y => y.UserProfileId, (x, y) => new ShareholderSearchViewModel { Id = y.ShareholderId, Email = x.Email, Name = x.name, ShareholderTypeCode = y.ShareholderTypeCode }).OrderBy(sortField); var result = query.Skip((model.Page - 1) * model.PageSize) .Take(model.PageSize); return(result.ToList()); }
public async Task <IActionResult> GetAllShareholders(ShareholderSearchModel searchModel = null, PageQueryParameters pageQueryParameters = null) { var filter = ShareholderSearchToFilterDto.Instance.Map(searchModel); var allshareholders = await shareholderService.GetAllShareholders(pageQueryParameters.PageNumber, pageQueryParameters.PageSize, filter); var listOfShareholdersVM = new PaginatedList <ShareholderDTO>(allshareholders); return(View(listOfShareholdersVM)); }
public async Task <ResponseModel <List <ShareholderSearchViewModel> > > SearchShareholder( [FromQuery] ShareholderSearchModel model) { var result = await _shareholderService.SearchShareholder(model); Response.StatusCode = (int)HttpStatusCode.OK; return(new ResponseBuilder <List <ShareholderSearchViewModel> >().Success() .Data(result) .Count(result.Count) .build()); }