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; } }
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; } }