public IHttpActionResult InsertIncidentReport(IncidentReportAC incidentReportAc)
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    var           userDetail    = _userDetailContext.GetUserDetailByUserName(HttpContext.Current.User.Identity.Name);
                    CompanyDetail companyDetail = _iCompanyRepository.GetCompanyDetailByUserId(userDetail.UserId);
                    if (companyDetail != null)
                    {
                        var incidentReportObject = _incidentReportRepository.GetIncidentReportByCompanyId(companyDetail.Id);
                        if (incidentReportObject == null)
                        {
                            MerchantService.DomainModel.Models.IncidentReport.IncidentReport incidentReport = new MerchantService.DomainModel.Models.IncidentReport.IncidentReport();
                            if (incidentReportAc != null)
                            {
                                incidentReport.AmountLimit = incidentReportAc.AmountLimit;
                                incidentReport.CompanyId   = companyId;
                                incidentReport.Comment     = incidentReportAc.Comment;
                                if (incidentReportAc.OperationTypeId == 52)
                                {
                                    incidentReport.StartDateTime = incidentReportAc.StartDateTime;
                                    incidentReport.EndDateTime   = incidentReportAc.EndDateTime;
                                }
                                incidentReport.OperationCounter = incidentReportAc.OperationCounter;
                                incidentReport.OperationTypeId  = incidentReportAc.OperationTypeId;
                                incidentReport.StatusId         = 4;
                                incidentReport.CreatedDateTime  = DateTime.UtcNow;
                                if (incidentReportAc.DurationId != 0)
                                {
                                    incidentReport.DurationTypeId = incidentReportAc.DurationId;
                                }

                                _incidentReportRepository.AddIncidentReport(incidentReport);
                                return(Ok(new { _isResult = true }));
                            }
                        }
                        else
                        {
                            return(Ok(new { _isResult = "AlreadyExists" }));
                        }
                    }
                    return(Ok(new { _isResult = false }));
                }
                else
                {
                    return(BadRequest());
                }
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }
        public IHttpActionResult GetIncidentReportList()
        {
            try
            {
                if (HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    var userDetail = _userDetailContext.GetUserDetailByUserName(HttpContext.Current.User.Identity.Name);
                    List <IncidentReportAC> listOfIncidentReportAC = new List <IncidentReportAC>();
                    CompanyDetail           companyDetail          = _iCompanyRepository.GetCompanyDetailByUserId(userDetail.UserId);
                    if (companyDetail != null)
                    {
                        List <MerchantService.DomainModel.Models.IncidentReport.IncidentReport> listOfIncidentReport = _incidentReportRepository.GetIncidentReportList(companyDetail.Id);
                        foreach (var incidentReportObject in listOfIncidentReport)
                        {
                            IncidentReportAC incidentReportAc = new IncidentReportAC();
                            incidentReportAc.OperationTypeId = incidentReportObject.OperationTypeId;
                            if (incidentReportObject.StartDateTime != null)
                            {
                                incidentReportAc.StartDateTime = Convert.ToDateTime(incidentReportObject.StartDateTime);
                                incidentReportAc.StartTime     = incidentReportAc.StartDateTime.TimeOfDay;
                            }
                            if (incidentReportObject.EndDateTime != null)
                            {
                                incidentReportAc.EndDateTime = Convert.ToDateTime(incidentReportObject.EndDateTime);
                                incidentReportAc.EndTime     = incidentReportAc.EndDateTime.TimeOfDay;
                            }
                            incidentReportAc.Id          = incidentReportObject.Id;
                            incidentReportAc.AmountLimit = incidentReportObject.AmountLimit;
                            incidentReportAc.DurationId  = incidentReportObject.DurationTypeId != null?Convert.ToInt32(incidentReportObject.DurationTypeId) : 0;

                            incidentReportAc.Comment          = incidentReportObject.Comment;
                            incidentReportAc.OperationCounter = incidentReportObject.OperationCounter;
                            incidentReportAc.Status           = incidentReportObject.StatusType != null ? incidentReportObject.StatusType.Name : "";
                            incidentReportAc.Operation        = incidentReportObject.ParamTypesForOperationType != null ? incidentReportObject.ParamTypesForOperationType.ValueEn : "";
                            listOfIncidentReportAC.Add(incidentReportAc);
                        }
                    }
                    return(Ok(listOfIncidentReportAC));
                }
                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;
            }
        }
        public IHttpActionResult GetIncidentReportForPosByCompanyId(int companyId)
        {
            try
            {
                List <MerchantService.DomainModel.Models.IncidentReport.IncidentReport> listOfIncidentReport = _incidentReportRepository.GetIncidentReportList(companyId);
                List <IncidentReportAC> listOfIncidentReportAC = new List <IncidentReportAC>();
                foreach (var incidentReportObject in listOfIncidentReport)
                {
                    IncidentReportAC incidentReportAc = new IncidentReportAC();
                    incidentReportAc.AmountLimit = incidentReportObject.AmountLimit;
                    incidentReportAc.Comment     = incidentReportObject.Comment;

                    if (incidentReportObject.StartDateTime != null)
                    {
                        incidentReportAc.StartDateTime = Convert.ToDateTime(incidentReportObject.StartDateTime);
                    }
                    if (incidentReportObject.EndDateTime != null)
                    {
                        incidentReportAc.EndDateTime = Convert.ToDateTime(incidentReportObject.EndDateTime);
                    }
                    if (incidentReportObject.DurationTypeId != null)
                    {
                        incidentReportAc.DurationId = Convert.ToInt32(incidentReportObject.DurationTypeId);
                    }

                    incidentReportAc.companyId      = incidentReportObject.CompanyId;
                    incidentReportAc.DurationTypeId = incidentReportObject.DurationTypeId != null?Convert.ToInt32(incidentReportObject.DurationTypeId) : 0;

                    incidentReportAc.OperationCounter = incidentReportObject.OperationCounter;
                    incidentReportAc.Status           = incidentReportObject.StatusType != null ? incidentReportObject.StatusType.Name : "";
                    incidentReportAc.Operation        = incidentReportObject.ParamTypesForOperationType != null ? incidentReportObject.ParamTypesForOperationType.ValueEn : "";
                    incidentReportAc.OperationTypeId  = incidentReportObject.OperationTypeId;
                    listOfIncidentReportAC.Add(incidentReportAc);
                }
                return(Ok(listOfIncidentReportAC));
            }
            catch (Exception ex)
            {
                _errorLog.LogException(ex);
                throw;
            }
        }