public List <WellWorkover> GetWorkoversBySearchDate(int searchMonth, int searchYear)
        {
            try
            {
                var wellWorkOvers = new WellWorkoverServices().GetAllOrderedWellWorkoversByMonth(searchMonth, searchYear);

                if (!wellWorkOvers.Any())
                {
                    return(new List <WellWorkover>());
                }

                wellWorkOvers.ForEach(m =>
                {
                    m.WellName      = m.Well.Name;
                    m.EquipmentName = m.Equipment.Name;
                    m.Reason        = m.WellWorkOverReason.Title;
                    m.MonthStr      = Enum.GetName(typeof(MonthList), m.Month);
                });
                return(wellWorkOvers);
            }
            catch (Exception ex)
            {
                return(new List <WellWorkover>());
            }
        }
        private List <WellWorkover> GetWellWorkovers(int itemsPerPage, int pageNumber, out int dataCount)
        {
            try
            {
                var wellWorkOvers = new WellWorkoverServices().GetAllOrderedWellWorkovers(itemsPerPage, pageNumber, out dataCount);

                ViewBag.PrDataCount = dataCount.ToString(CultureInfo.InvariantCulture);

                var totalPages = dataCount / itemsPerPage;

                // Counting the last page
                if (dataCount % itemsPerPage != 0)
                {
                    totalPages++;
                }

                ViewBag.PrTotalPages = totalPages;
                ViewBag.PrPage       = pageNumber;
                if (!wellWorkOvers.Any())
                {
                    return(new List <WellWorkover>());
                }

                wellWorkOvers.ForEach(m =>
                {
                    m.WellName       = m.Well.Name;
                    m.EquipmentName  = m.Equipment.Name;
                    m.Reason         = m.WellWorkOverReason.Title;
                    m.MonthStr       = Enum.GetName(typeof(MonthList), m.Month);
                    m.WorkoverPeriod = m.Month + "/" + m.Year;
                });

                return(wellWorkOvers);
            }
            catch (Exception ex)
            {
                ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message);
                dataCount = 0;
                return(new List <WellWorkover>());
            }
        }
示例#3
0
        private List <DocObject> GetYears()
        {
            var jxs = new WellWorkoverServices().GetWellWorkoverYears();

            if (!jxs.Any())
            {
                return(new List <DocObject>());
            }
            var tdv = new List <DocObject>();

            jxs.ForEach(m =>
            {
                var ts = m;

                if (!tdv.Exists(t => t.DocId == ts))
                {
                    tdv.Add(new DocObject {
                        DocName = m.ToString(CultureInfo.InvariantCulture), DocId = ts
                    });
                }
            });
            return(tdv.OrderByDescending(m => m.DocName).ToList());
        }