コード例 #1
0
        public async Task <IActionResult> Index(int?idCategorie, DateTime?dateSelected)
        {
            // Recuperation du filtre si celui a été activé
            CookieFilterOperation cookie = new CookieFilterOperation().GetCookieFilterOperation(Request);

            if (cookie != null && cookie.Activer)
            {
                idCategorie  = cookie.IdCategorie;
                dateSelected = cookie.DateSelected;
            }
            cookie = new CookieFilterOperation(idCategorie, dateSelected, false, Response);

            OperationViewModel operationVM = new OperationViewModel();

            operationVM.IdCategorie  = idCategorie;
            operationVM.DateSelected = dateSelected;
            var categories = _categorieService.ListAll().OrderBy(C => C.Libelle);

            operationVM.ListOperations = await _operationService.ListFilterWithGraphAsync(idCategorie, dateSelected);

            operationVM.TotalDepenses = _operationService.getTotalDepensesCourant(operationVM.ListOperations);
            operationVM.TotalRecettes = _operationService.getTotalRecettesCourant(operationVM.ListOperations);

            operationVM.Categories = new SelectList(categories, "Id", "Libelle");
            return(View(operationVM));
        }
コード例 #2
0
        public void ActiverCookieFilterOperation(HttpRequest request, HttpResponse response)
        {
            CookieFilterOperation cookie = GetCookieFilterOperation(request);

            cookie.Activer = true;
            response.Cookies.Append(Constant.COOKIE_FILTER, JsonConvert.SerializeObject(cookie));
        }