public ActionResult Details(SearchCriteria searchCriteria) { int totalcount = 0; IEnumerable <AttendanceRecord> recordsList; var manager = new DBManager("DetailsTable"); if (searchCriteria.month.HasValue || searchCriteria.year.HasValue || searchCriteria.prNo.HasValue) //hasvalue cahnaged { recordsList = manager.GetRecordsBySearch(searchCriteria.month, searchCriteria.year, searchCriteria.prNo); totalcount = recordsList.Count(); searchCriteria.pgNo = searchCriteria.pgNo.HasValue ? searchCriteria.pgNo.Value : 1; searchCriteria.entries = searchCriteria.entries.HasValue ? searchCriteria.entries.Value : 10; recordsList = recordsList.Skip((searchCriteria.pgNo.Value - 1) * searchCriteria.entries.Value).Take(searchCriteria.entries.Value); } else { recordsList = manager.GetRecords(searchCriteria.pgNo, searchCriteria.entries); totalcount = manager.GetTotalRecords(); } var searchCustomerViewModel = new SearchCustomerViewModel() { totalCount = totalcount, AttendanceRecords = recordsList, SearchCriteria = searchCriteria }; return(View(searchCustomerViewModel)); }
//[HttpPost] //[ValidateAntiForgeryToken] public IActionResult SearchCustomerByName(string name, string city, int amount, int pagenr) { if (ModelState.IsValid) { var model = new SearchCustomerViewModel() { Name = name, Amount = amount, PageNr = pagenr }; var request = new GetCustomerByNamesCityRequest() { City = city, Search = name, Limit = amount, Offset = (amount * pagenr) }; var response = new GetCustomersByNamesCityHandler().Handler(request); model.Name = name; model.Amount = amount; model.PageNr = pagenr; model.City = city; model.Customers = response.Customers; model.TotalCustomers = response.TotalCustomerAmount; model.TotalPages = response.TotalNumberOfPages; return(PartialView("_CustomerListPartial", model)); } return(NotFound()); }
public async Task <ActionResult> SearchCustomers(SearchCustomerViewModel model, CancellationToken cancellationToken) { EnsureModalStateIsValid(); var request = Mapper.Map <SearchCustomerViewModel, SearchCustomersRequest>(model); var response = await Mediator.Send(request, cancellationToken); return(await HandleResponse(response, cancellationToken)); }
public ActionResult SearchResults(SearchCustomerViewModel model) { try { model.SearchResults = adminQueries.GetSearchCustomerDetails(model); } catch (Exception ex) { throw new Exception(ex.Message); } return(View(model)); }
public IActionResult SearchCustomerById(SearchCustomerViewModel model) { var request = new GetCustomerByIdRequest() { Id = model.CustomerId }; var response = new GetCustomerByIdHandler().Handler(request); model.Customers.Add(response.Customer); model.TotalCustomers = 1; model.TotalPages = 1; return(PartialView("_CustomerListPartial", model)); }
public IActionResult Get([FromQuery] SearchCustomerViewModel model) { if (!ModelState.IsValid) { return(BadRequest(GetModelStateErrorResponse(ModelState))); } var resp = Search(model); if (resp.Type != ResponseType.Success) { return(BadRequest(resp)); } return(Ok(resp)); }
public IQueryable <CustomerDetail> GetCustomerDetails(SearchCustomerViewModel model) { var query = customerRepository.GetCustomers(); if (model == null) { return(query); } if (!string.IsNullOrEmpty(model.TypeofInsurance)) { query = query.GetCustomersByInsurance(model.TypeofInsurance); } if (!string.IsNullOrEmpty(model.FirstName)) { query = query.GetCustomersByFistName(model.FirstName); } if (!string.IsNullOrEmpty(model.LastName)) { query = query.GetCustomersByLastName(model.LastName); } if (!string.IsNullOrEmpty(model.location)) { query = query.GetCustomersByLocation(model.location); } int age; if (!string.IsNullOrEmpty(model.AgeEquality) && !string.IsNullOrEmpty(model.Age) && int.TryParse(model.Age, out age)) { query = query.GetCustomersByAge(age, model.AgeEquality); } int years; if (!string.IsNullOrEmpty(model.YearsEuality) && !string.IsNullOrEmpty(model.NumOfYears) && int.TryParse(model.NumOfYears, out years)) { query = query.GetCustomersByYears(years, model.YearsEuality); } double amount; if (!string.IsNullOrEmpty(model.AmountEuality) && !string.IsNullOrEmpty(model.AmountEuality) && double.TryParse(model.Amount, out amount)) { query = query.GetCustomersByAmount(amount, model.AmountEuality); } query = query.GetCustomersByStatus(model.Status); return(query.OrderByDescending(x => x.DateCreated)); }
public List <SearchCustomerDetails> GetSearchCustomerDetails(SearchCustomerViewModel model) { var results = GetCustomerDetails(model); var res = results.Select(x => new SearchCustomerDetails() { Fullname = string.Concat(x.Firstname, " ", x.Lastname), CustomerAge = x.CustomerAge, NumOfYears = x.NumOfYears, Amount = x.Amount, Status = x.Status.Value, TypeofInsurance = x.TypeofInsurance, Location = x.Location, CustomerID = x.CustomerID, ID = x.ID }); return(res.ToList()); }
private ApiResponse <PagedListResponse <CustomerViewModel> > Search(SearchCustomerViewModel model) { var apiResp = new ApiResponse <PagedListResponse <CustomerViewModel> > { Type = ResponseType.Fail, Data = new PagedListResponse <CustomerViewModel>() }; var request = new FilteredPagedListRequest <SearchCustomerCriteria> { FilterCriteria = new SearchCustomerCriteria { AuthorizedPersonName = model.AuthorizedPersonName, Title = model.Title, UserId = GetUserId().Value, SortType = model.GetSortType() }, IncludeRecordsTotal = model.IncludeRecordsTotal, Limit = model.Limit, Offset = model.Offset }; var resp = _customerBusiness.Search(request); apiResp.Data.Items = resp.Items.Select(p => new CustomerViewModel { Id = p.Id, Title = p.Title, AuthorizedPersonName = p.AuthorizedPersonName, CreatedAt = p.CreatedAt, PhoneNumber = p.PhoneNumber, DebtBalance = p.DebtBalance, ReceivableBalance = p.ReceivableBalance }); apiResp.Data.RecordsTotal = resp.RecordsTotal; apiResp.Type = ResponseType.Success; return(apiResp); }
public SearchCustomerViewModel FilteredByNameAndCity(SearchCustomerViewModel model)//string name, string city, int page) { // string name = model.Name; // string city = model.City; int page = model.CurrentPage; if (model.Customers != null) { if (model.Customers.Count() == 50) { SetNextPageResults(page++); } else if (model.Customers.Count() < 50 && page != 0) { model.MoreResults = false; SetNextPageResults(page); } } if (model.Name != null && model.City != null) { model.SetCustomerList(BasedOnNameAndCity(model.Name, model.City)); return(model); } else if (model.Name != null && model.City == null) { model.SetCustomerList(BasedOnName(model.Name)); return(model); } else if (model.Name == null && model.City != null) { model.SetCustomerList(BasedOnCity(model.City)); return(model); } model.SetCustomerList(new List <Customer>()); return(model); // Om inget är angivet - ska inte ge något resultat från databasen }
public ActionResult Index(SearchCustomerViewModel model) { var query = db.CustomerDetails.Where(x => x.TypeofInsurance == model.TypeofInsurance).ToList(); return(View(query)); }
public SearchCustomerPage() { InitializeComponent(); _viewModel = new SearchCustomerViewModel(); BindingContext = _viewModel; }
public IActionResult DisplayCustomerSearchList(SearchCustomerViewModel model, int page) { model.CurrentPage = page; model = new GetCustomers(_context).FilteredByNameAndCity(model); return(View(model)); }