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;
     }
 }
        public IHttpActionResult UpdateIncidentReport(IncidentReportAC incidentReportAC)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    var incidentReportObject = _incidentReportRepository.GetIncidentReportById(incidentReportAC.Id);
                    if (incidentReportObject != null)
                    {
                        incidentReportObject.OperationCounter = incidentReportAC.OperationCounter;
                        incidentReportObject.AmountLimit      = incidentReportAC.AmountLimit;
                        incidentReportObject.Comment          = incidentReportAC.Comment;
                        incidentReportObject.OperationTypeId  = incidentReportAC.OperationTypeId;
                        incidentReportObject.DurationTypeId   = incidentReportAC.DurationId;

                        if (incidentReportAC.StartDateTime != default(DateTime))
                        {
                            incidentReportObject.StartDateTime = incidentReportAC.StartDateTime;
                        }

                        if (incidentReportAC.EndDateTime != default(DateTime))
                        {
                            incidentReportObject.EndDateTime = incidentReportAC.EndDateTime;
                        }

                        _incidentReportRepository.UpdateIncidentReport(incidentReportObject);
                        List <CashierIncidentReport> listOfCashierIncidentReport = _incidentReportRepository.GetListOfCashierIncidentReportByCompanyId(incidentReportObject.CompanyId);
                        foreach (var cashierIncidentReport in listOfCashierIncidentReport)
                        {
                            cashierIncidentReport.IsRefreshRequset = true;
                            cashierIncidentReport.IsResetRequest   = true;
                            cashierIncidentReport.ModifiedDateTime = DateTime.UtcNow;
                            _incidentReportRepository.UpdateCashierIncidentReportByCashier(cashierIncidentReport);
                        }
                        return(Ok(new { _isResult = true }));
                    }
                    return(Ok(new { _isResult = false }));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }