Пример #1
0
        public ActionResult ExportIncident()
        {
            var    incidentList = new List <HseInjuredSafetyIncidentView>();
            string txtDate      = Request["txtDate"];

            Expression <Func <HseInjuredSafetyIncidentEntity, bool> > predicate = x => x.Id > 0 && x.IsDeleted == false;

            if (!string.IsNullOrEmpty(txtDate))
            {
                DateTime dateTime = Convert.ToDateTime(txtDate);
                DateTime dateAdd  = dateTime.AddDays(1);
                predicate = predicate.AndAlso(a => a.OccurrenceDate == dateTime);
            }

            var list = _hseInjuredSafetyIncidentService.GetList <HseInjuredSafetyIncidentView>(predicate).OrderByDescending(x => x.Id).ToList();

            incidentList = (from m in list
                            select new HseInjuredSafetyIncidentView
            {
                Id = m.Id,
                PatientInfo = m.PatientInfo,
                PatientName = m.PatientName == null ? m.ReportedUserName : m.PatientName,
                PatientLillyId = m.PatientLillyId == null ? m.CreatedUserID : m.PatientLillyId,
                OccurrenceDate = m.OccurrenceDate,
                Location = SafetyReportHelper.GetLocation(m.Location) == "" ? m.OtherLocation : SafetyReportHelper.GetLocation(m.Location),
                OtherLocation = m.OtherLocation,
                InjuredType = SafetyReportHelper.GetInjuredType(m.InjuredType),
                InjurySites = SafetyReportHelper.GetInjurySites(m.InjurySites) == "" ? m.OtherInjurySites : SafetyReportHelper.GetInjurySites(m.InjurySites),
                OtherInjurySites = m.OtherInjurySites,
                Description = m.Description,
                ReportedUserName = m.ReportedUserName,
                CreatedUserID = m.CreatedUserID,
                CreatedDate = m.CreatedDate
            }).ToList();

            return(ExportToIncidentCsv(incidentList));
        }