public async Task <IActionResult> Statistics(RepairSearchRequest searchStatistics) { var statistics = await _repairService.GetRepairStatusCountAsync(); if (searchStatistics.ArePropertiesNotNull()) { statistics = await _repairService.GetRepairStatusCountBySearchAsync(searchStatistics); } return(View(statistics)); }
public async Task <Statistics> GetRepairStatusCountBySearchAsync(RepairSearchRequest searchStatistics) { var searchFilter = new Repair(); searchFilter = _repairMappingProfile.ConvertRepairSearchRequestToRepair(searchStatistics, searchFilter); var repair = await _unitOfWork.Repairs.GetRepairBySearchDateAsync(searchStatistics.DateFrom, searchStatistics.DateTo, searchFilter); var statisticsData = new Statistics(); statisticsData.New = repair.Count(x => x.RepairStatusId == 1); statisticsData.Priced = repair.Count(x => x.RepairStatusId == 2); statisticsData.InProgress = repair.Count(x => x.RepairStatusId == 3); statisticsData.Completed = repair.Count(x => x.RepairStatusId == 5); statisticsData.Rejected = repair.Count(x => x.RepairStatusId == 7); return(statisticsData); }
public async Task <IActionResult> Index(RepairSearchRequest repairSearch) { var model = await _repairService.GetAllRepairsAsync(); try { if (ControllerHelperMethods.ArePropertiesNotNull(repairSearch)) { model = await _repairService.GetRepairBySearchTermsAsync(repairSearch); } return(View(model)); } catch (ArgumentNullException) { var emptyList = new List <RepairResponse>(); return(View(emptyList)); } }
public Repair ConvertRepairSearchRequestToRepair(RepairSearchRequest _repairSearchRequest, Repair repair) { repair.RepairStatus = new RepairStatus() { Name = _repairSearchRequest.StatusName }; repair.Product = new Product() { Producer = _repairSearchRequest.ProducerName, Model = _repairSearchRequest.ModelName }; repair.Customer = new Customer() { Name = _repairSearchRequest.CustomerName, LastName = _repairSearchRequest.CustomerLastName, Email = _repairSearchRequest.Email, PhoneNum = _repairSearchRequest.PhoneNumber }; return(repair); }
public async Task <IViewComponentResult> InvokeAsync() { var repairSearch = new RepairSearchRequest(); return(View("RepairSearch", repairSearch)); }
public async Task <IEnumerable <RepairResponse> > GetRepairBySearchTermsAsync(RepairSearchRequest searchRequest) { var searchFilter = new Repair(); searchFilter = _repairMappingProfile.ConvertRepairSearchRequestToRepair(searchRequest, searchFilter); var repair = await _unitOfWork.Repairs.GetRepairBySearchTermsAsync(searchRequest.DateFrom, searchRequest.DateTo, searchFilter); _nullCheckMethod.CheckIfResponseListIsEmpty(repair); var response = Mapper.Map <IEnumerable <RepairResponse> >(repair); return(response); }