public doMaintenanceCheckSheetReportView(doMaintenanceCheckSheetReport main, doMaintenanceCheckSheetReport m1, doMaintenanceCheckSheetReport m2, doMaintenanceCheckSheetReport r1)
 {
     _main = (main ?? m1 ?? m2 ?? r1);
     if (_main == null)
     {
         throw new ArgumentNullException("all parameters cannot be null.");
     }
     _m1 = m1;
     _m2 = m2;
     _r1 = r1;
 }
        public static List <doMaintenanceCheckSheetReportView> ToReportViewList(this List <doMaintenanceCheckSheetReport> data)
        {
            var lstView = new List <doMaintenanceCheckSheetReportView>();

            if (data != null)
            {
                doMaintenanceCheckSheetReport main = data.FirstOrDefault();

                if (main != null)
                {
                    var lstM = data.Where(d => d.Type == "M").OrderBy(d => d.InstrumentCode).ToList(); //Maintenance Instrument
                    var lstR = data.Where(d => d.Type == "R").OrderBy(d => d.InstrumentCode).ToList(); //Replace Instrument

                    int     rowsperpage = (main.RowsPerPage > 0 ? main.RowsPerPage : ROWS_PER_PAGE);
                    decimal totalrows   = Math.Max(Math.Ceiling(lstM.Count / 2m), lstR.Count);
                    if (totalrows <= 0)
                    {
                        totalrows = rowsperpage;
                    }

                    decimal totalpages = Math.Ceiling(totalrows / rowsperpage);

                    for (int page = 0; page < totalpages; page++)
                    {
                        for (int i = 0; i < rowsperpage; i++)
                        {
                            int idxM1, idxM2, idxR1;
                            idxM1 = (page * rowsperpage * 2) + i;
                            idxM2 = (page * rowsperpage * 2) + rowsperpage + i;
                            idxR1 = i;

                            doMaintenanceCheckSheetReport m1, m2, r1;
                            m1 = (idxM1 >= lstM.Count ? null : lstM[idxM1]);
                            m2 = (idxM2 >= lstM.Count ? null : lstM[idxM2]);
                            r1 = (idxR1 >= lstR.Count ? null : lstR[idxR1]);

                            lstView.Add(new doMaintenanceCheckSheetReportView(main, m1, m2, r1));
                        }
                    }
                }
            }

            return(lstView);
        }
 public doMaintenanceCheckSheetReportView(doMaintenanceCheckSheetReport main, doMaintenanceCheckSheetReport m1, doMaintenanceCheckSheetReport m2) : this(main, m1, m2, null)
 {
 }
 public doMaintenanceCheckSheetReportView()
 {
     _m1 = new doMaintenanceCheckSheetReport();
 }