public async Task <ActionResult <PaginatedItems <CustomerUserData> > > GetListCustomerUserCessation(string nroDni, string fullname, DateTime?startDate, DateTime?endDate, [FromQuery] int pageSize = 10, [FromQuery] int pageIndex = 0) { var user = await _customerUserRepository.GetCustomerUserByDni(nroDni); if (user == null) { return(StatusCode(StatusCodes.Status400BadRequest)); } CustomerCessationSearch search = new CustomerCessationSearch { ChiefCustomerId = user.CustomerId, FullName = fullname ?? "", StartDate = startDate == null ? null : startDate, EndtDate = endDate == null ? null : endDate }; var response = await _customerUserRepository.GetListCustomerUserTermination(search); var totalItems = response.Count(); var itemsOnPage = response .Skip(pageSize * pageIndex) .Take(pageSize) .ToList(); return(new PaginatedItems <CustomerUserData>(pageIndex, pageSize, totalItems, itemsOnPage)); }
public async Task <IEnumerable <CustomerUserData> > GetListCustomerUserTermination(CustomerCessationSearch search) { var response = await _OTRSContext.SpListUserCese.FromSqlInterpolated( $"CALL sp_list_user_cese({search.ChiefCustomerId},{search.FullName},{search.StartDate},{search.EndtDate});" ).ToListAsync(); var result = (from cu in response select new CustomerUserData { Id = cu.Id, Email = cu.Email, CustomerId = cu.CustomerId, Dni = cu.Dni, FirstName = cu.FirstName, LastName = cu.LastName, RenewalDate = cu.RenewalDate, RenewalStatus = cu.RenewalDate == null ? false : true, TerminationDate = cu.TerminationDate }).ToList(); return(result); }