Beispiel #1
0
        public static void SetListExpenseSubcategories(int dossierId)
        {
            List <recordSubcategory> list = new List <recordSubcategory>();

            //TODO: replace with a generic method with EF implememntation
            ObjectResult <GetrecordSubcategoriesByDossierId_Result> listTmp = _context.GetrecordSubcategoriesByDossierId(dossierId);

            foreach (var item in listTmp)
            {
                recordSubcategory expsc = new recordSubcategory();
                expsc.recordCategoryId    = item.recordCategoryId;
                expsc.recordSubcategoryId = item.recordSubcategoryId;
                expsc.description         = item.description;

                list.Add(expsc);
            }

            HttpContext.Current.Session["ListExpenseSubcategories" + dossierId] = list;
        }
        private List <recordSubcategory> GetListExpenseSubcategories(int dossierId)
        {
            List <recordSubcategory> list = new List <recordSubcategory>();

            ObjectResult <GetrecordSubcategoriesByDossierId_Result> listTmp = _context.GetrecordSubcategoriesByDossierId(dossierId);

            //TODO: replace with a generic method with EF implememntation
            //ObjectResult<GetrecordSubcategoriesByDossierId_Result> listTmp = _context.GetrecordSubcategoriesByDossierId(dossierId);

            foreach (var item in listTmp)
            {
                recordSubcategory expsc = new recordSubcategory();
                expsc.recordCategoryId    = item.recordCategoryId;
                expsc.recordSubcategoryId = item.recordSubcategoryId;
                expsc.description         = item.description;

                list.Add(expsc);
            }

            return(list);
        }
        public DossierDetailsModel(int dossierId, string ConnectionString = "")
        {
            _dossier = (from d in _context.dossiers
                        where d.dossierId == dossierId
                        select new POCO.dossier {
                dossierId = d.dossierId,
                creationDate = d.creationDate,
                dossierName = d.dossierName,
                userId = d.userId
            }).FirstOrDefault();

            _dossierId = dossierId;

            //userName

            _userName = (from d in _context.dossiers
                         join u in _context.AspNetUsers on d.userId equals u.Id
                         where d.dossierId == dossierId
                         select u.UserName).Single();



            _RecordCategories = (from sc in (_context.recordCategories.Where(ec => ec.dossierId == dossierId).ToList())
                                 select new POCO.recordCategory
            {
                description = sc.description,
                dossierId = sc.dossierId,
                isExpense = sc.isExpense,
                recordCategoryId = sc.recordCategoryId,
            }).ToList();



            //TODO: test both methods
            _endYear   = StoreProcedures.GetMaxYearDossier(dossierId);
            _beginYear = StoreProcedures.GetMinYearDossier(dossierId);


            var _RecordSubcategoriesResult = _context.GetrecordSubcategoriesByDossierId(dossierId);

            _RecordSubcategories = (from rscr in _RecordSubcategoriesResult
                                    select new POCO.recordSubcategory
            {
                description = rscr.description,
                recordCategoryId = rscr.recordCategoryId,
                recordSubcategoryId = rscr.recordCategoryId
            }).ToList();


            var myDate  = DateTime.Now;
            var newDate = myDate.AddYears(-1);

            newDate = newDate.AddDays(1);

            string beginDate365dd = Utils.Utils.FormatDate(newDate);
            string endDate365dd   = Utils.Utils.FormatDate(DateTime.Now);

            IncomeStatementTab expenses = new IncomeStatementTab(dossierId, beginDate365dd, endDate365dd, true);
            IncomeStatementTab revenues = new IncomeStatementTab(dossierId, beginDate365dd, endDate365dd, false);

            try
            {
                if (!string.IsNullOrEmpty(ConnectionString))
                {
                    SetStringArrayJS(expenses, ConnectionString);
                }
            }
            catch (Exception)
            {
            }

            _overallExpensesLast365 = expenses.totalDec;
            _overallRevenuesLast365 = revenues.totalDec;


            //var mostExpensiveCategories = (from ex in expenses.report
            //                                where ex.bitmap == 1
            //                                orderby ex.total descending
            //                                select ex.category).Take(4);


            //var ado = new AdoRepository<POCO.yearlyExpensePerCategoryLine>(ConnectionString);



            //_yearlyExpensePerCategoryLines = ado.YearlyExpensePerCategory(dossierId,
            //                                                              mostExpensiveCategories.ElementAt(0),
            //                                                              mostExpensiveCategories.ElementAt(1),
            //                                                              mostExpensiveCategories.ElementAt(2),
            //                                                              mostExpensiveCategories.ElementAt(3),
            //                                                              true);
        }