public List <Production> GetProducttionsBySearchDate(GenericSearch search) { try { var productions = new ProductionServices().GetAllOrderedProductionsByMonth(search.Month, search.Year); if (!productions.Any()) { return(new List <Production>()); } productions.ForEach(m => { m.FieldName = m.Field.Name; m.ProductName = m.Product.Name; m.MonthName = Enum.GetName(typeof(MonthList), m.Month); m.Quantity = Convert.ToDecimal(m.Quantity).ToString("#,##0"); }); return(productions); } catch (Exception ex) { ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(new List <Production>()); } }
private List <DocObject> GetYears() { var jxs = new ProductionServices().GetProductionYears(); if (!jxs.Any()) { return(new List <DocObject>()); } var tdv = new List <DocObject>(); jxs.ForEach(m => { if (!tdv.Exists(t => t.DocId == m)) { tdv.Add(new DocObject { DocName = m.ToString(CultureInfo.InvariantCulture), DocId = m }); } }); return(tdv.OrderByDescending(m => m.DocName).ToList()); }
private List <Production> GetProductions(int itemsPerPage, int pageNumber, out int dataCount) { try { var productionList = new ProductionServices().GetAllOrderedProductions(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 (!productionList.Any()) { return(new List <Production>()); } productionList.ForEach(m => { m.FieldName = m.Field.Name; m.ProductName = m.Product.Name; m.Quantity = Convert.ToDecimal(m.Quantity).ToString("#,##0"); m.MonthName = Enum.GetName(typeof(MonthList), m.Month); }); return(productionList); } catch (Exception ex) { dataCount = 0; ErrorLogger.LogEror(ex.StackTrace, ex.Source, ex.Message); return(new List <Production>()); } }