private IncidentReportWorkListAC GetCashierIncidentReport(int userId, bool isReset, List <CashierIncidentReport> listOfCashierIncidentReport) { try { IncidentReportWorkListAC incidentReportWorkListAC = new IncidentReportWorkListAC(); List <CashierIncidentReport> mainCashierIncidentReport = listOfCashierIncidentReport.Where(x => x.UserId == userId && x.IsRefreshRequset == isReset).OrderByDescending(x => x.CreatedDateTime).ToList(); decimal mainTotalAmount = 0; foreach (var mainItem in mainCashierIncidentReport) { mainTotalAmount = mainTotalAmount + mainItem.AmountLimit; } incidentReportWorkListAC.OperationCount = mainCashierIncidentReport.Count; incidentReportWorkListAC.Amount = mainTotalAmount; if (mainCashierIncidentReport.Count > 0) { if (mainCashierIncidentReport[0].UserDetail != null) { incidentReportWorkListAC.BranchId = Convert.ToInt32(mainCashierIncidentReport[0].UserDetail.BranchId); incidentReportWorkListAC.BranchName = mainCashierIncidentReport[0].UserDetail.Branch != null ? mainCashierIncidentReport[0].UserDetail.Branch.Name : ""; incidentReportWorkListAC.CashierName = mainCashierIncidentReport[0].UserDetail.UserName; } incidentReportWorkListAC.ReachedDateTime = mainCashierIncidentReport[0].CreatedDateTime; incidentReportWorkListAC.ModifiedDate = mainCashierIncidentReport[0].ModifiedDateTime; incidentReportWorkListAC.CashierId = userId; } return(incidentReportWorkListAC); } catch (Exception) { throw; } }
public IHttpActionResult GetIncidentReportWorkList() { try { List <IncidentReportWorkListAC> incidentReportWorkList = new List <IncidentReportWorkListAC>(); if (HttpContext.Current.User.Identity.IsAuthenticated) { //Get Incident Report By Comapany Id. IncidentReport incidentReport = _incidentReportRepository.GetIncidentReportByCompanyId(companyId); if (incidentReport != null) { //Get Cashier Incident Report BY Company Id. List <CashierIncidentReport> listOfCashierIncidentReport = _incidentReportRepository.GetListOfCashierIncidentReportByCompanyId(companyId); if (listOfCashierIncidentReport.Count > 0) { //Group By Cashier. var cashierIncidentList = listOfCashierIncidentReport.GroupBy(x => x.UserId); foreach (var cashierIncidentReport in cashierIncidentList) { var incidentReportDeatil = GetCashierIncidentReport(cashierIncidentReport.Key, false, listOfCashierIncidentReport); if (incidentReportDeatil.Amount >= incidentReport.AmountLimit || incidentReportDeatil.OperationCount >= incidentReport.OperationCounter) { IncidentReportWorkListAC incidentReportWorkListAC = new IncidentReportWorkListAC(); incidentReportWorkListAC.Amount = incidentReportDeatil.Amount; incidentReportWorkListAC.OperationCount = incidentReportDeatil.OperationCount; incidentReportWorkListAC.ReachedDateTime = incidentReportDeatil.ReachedDateTime; incidentReportWorkListAC.BranchName = incidentReportDeatil.BranchName; incidentReportWorkListAC.BranchId = incidentReportDeatil.BranchId; incidentReportWorkListAC.ModifiedDate = incidentReportDeatil.ModifiedDate; incidentReportWorkListAC.CashierId = incidentReportDeatil.CashierId; incidentReportWorkListAC.CashierName = incidentReportDeatil.CashierName; List <CashierIncidentReport> checkCashierIncidentReportListCount = listOfCashierIncidentReport.Where(x => x.UserId == cashierIncidentReport.Key && x.IsRefreshRequset == true).OrderByDescending(x => x.CreatedDateTime).ToList(); if (checkCashierIncidentReportListCount.Count > 0) { incidentReportWorkListAC.HasChildItem = true; List <SubIncidentReportWorkListAC> listOfSubIncidentReportWorkListAC = GetSubIncidentReportWorkFlowListAC(checkCashierIncidentReportListCount); incidentReportWorkListAC.ListOfSubIncidentReportWorkListAC = listOfSubIncidentReportWorkListAC; } incidentReportWorkList.Add(incidentReportWorkListAC); } } } } return(Ok(incidentReportWorkList)); } else { return(BadRequest()); } } catch (Exception ex) { _errorLog.LogException(ex); throw; } }
/// <summary> /// This method used for get list Of Incident Report WorkList. -An /// </summary> /// <returns></returns> public List <IncidentReportWorkListAC> listOfIncidentReportWorkListAC(int companyId) { try { List <IncidentReportWorkListAC> listOfIncidentReportWorkFlowList = new List <IncidentReportWorkListAC>(); IncidentReport incidentReport = _incidentReportContext.FirstOrDefault(x => x.CompanyId == companyId); if (incidentReport != null) { List <CashierIncidentReport> listOfCashierIncidentReport = _cashierIncidentReportCotext.Fetch(x => (x.OperationCounter >= incidentReport.OperationCounter || x.AmountLimit >= incidentReport.AmountLimit) && x.UserDetail.Branch.CompanyId == incidentReport.CompanyId).ToList(); foreach (var cashierIncidentReport in listOfCashierIncidentReport) { IncidentReportWorkListAC incidentReportWorkListAc = new IncidentReportWorkListAC(); incidentReportWorkListAc.Id = cashierIncidentReport.Id; incidentReportWorkListAc.CashierId = cashierIncidentReport.UserDetail.Id; incidentReportWorkListAc.CashierName = cashierIncidentReport.UserDetail.UserName; if (cashierIncidentReport.ParentRecord != null) { WorkFlowLog workFlowLog = _workFlowLogContext.Fetch(x => x.RecordId == cashierIncidentReport.ParentRecord.Id).OrderBy(x => x.CreatedDateTime).FirstOrDefault(); if (workFlowLog != null) { incidentReportWorkListAc.Comment = workFlowLog.Comments; } } incidentReportWorkListAc.ReachedDateTime = cashierIncidentReport.CreatedDateTime; incidentReportWorkListAc.BranchName = cashierIncidentReport.UserDetail.Branch.Name; incidentReportWorkListAc.BranchId = cashierIncidentReport.UserDetail.BranchId != null?Convert.ToInt32(cashierIncidentReport.UserDetail.BranchId) : 0; listOfIncidentReportWorkFlowList.Add(incidentReportWorkListAc); } } return(listOfIncidentReportWorkFlowList); } catch (Exception ex) { _errorLog.LogException(ex); throw; } }