Ejemplo n.º 1
0
        public ActionResult RenderNoticesBoxes(ContractNoticesViewModel model)
        {
            SetCulture(model.CurrentPageCulture);

            var _model = _noticesService.GetNoticeBoxesModel(model);

            return(PartialView("NoticesPartial", _model));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Metorda zwracająca klasę zawierającą elementy wyświetlane na stronie wszytskich zamówień publicznych
        /// </summary>
        /// <param name="currentUmbracoPageId">id strony umbraco na której się znajdujemy</param>
        /// <returns>Model zawierający elementy strony ze wszytskimi zamówieniami publicznymi</returns>
        public ContractNoticesViewModel GetNoticeBoxesModel(int currentUmbracoPageId, TempDataDictionary tempData)
        {
            var _model = new ContractNoticesViewModel();

            _model.CurrentUmbracoPageId = currentUmbracoPageId;
            _model.CurrentPageCulture   = Thread.CurrentThread.CurrentCulture;

            var _filterStateCookie = CookiesExtensions.GetCookieValue(CookieVariables.ContractsFilterCookie);

            if (string.IsNullOrEmpty(_filterStateCookie))
            {
                return(GetNoticeBoxesModel(_model));
            }

            var _filterModel = JsonConvert.DeserializeObject <ContractsFilterStateModel>(StringExtensions.Base64Decode(_filterStateCookie));

            if (_filterModel == null)
            {
                return(GetNoticeBoxesModel(_model));
            }

            _model.SelectedStatusId         = _filterModel.SelectedStatusId;
            _model.SelectedAdministrativeId = _filterModel.SelectedAdministrativeId;
            _model.SelectedLawActId         = _filterModel.SelectedLawActId;
            _model.SelectedTypeOfContractId = _filterModel.SelectedTypeOfContractId;

            if (!string.IsNullOrWhiteSpace(_filterModel.Name))
            {
                _model.Name = _filterModel.Name;
            }
            if (!string.IsNullOrWhiteSpace(_filterModel.Number))
            {
                _model.Number = _filterModel.Number;
            }
            if (_filterModel.StartDate.HasValue)
            {
                _model.StartDate = _filterModel.StartDate.Value;
            }
            if (_filterModel.EndDate.HasValue)
            {
                _model.EndDate = _filterModel.EndDate.Value;
            }

            return(GetNoticeBoxesModel(_model));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Metorda zwracająca klasę zawierającą elementy wyświetlane na stronie wszytskich zamówień publicznych
        /// </summary>
        /// <param name="model">Obiekt klasy ContractNoticesViewModel</param>
        /// <returns>Gotowy model do wyświetlenia na stronie wszystkich zamówień publicznych</returns>
        public ContractNoticesViewModel GetNoticeBoxesModel(ContractNoticesViewModel model)
        {
            var _noticesNode = _umbracoHelper.TypedContent(model.CurrentUmbracoPageId);
            var _noticesList = _noticesNode.Children.Where("Visible").Select(q => new ContractNotice(q));
            var _noticesItem = new ContractNotices(_noticesNode);

            model.DisplayCount = _noticesItem.DisplayItemCount;
            model.ArchiveUrl   = _noticesItem.ArchiveUrl;

            #region Pobranie filtrów z bazy danych
            //Pobranie aktywnych filtrów z bazy danych
            var _administrativeFilterItemsFromDB = _dbService.GetAll <AdministrativeDB>("PolRegioAdministrative", q => q.IsEnabled);

            model.AdministrativeFilter = _administrativeFilterItemsFromDB.Select(q => new FilterItem()
            {
                Id = q.Id, DisplayText = _umbracoHelper.GetDictionaryValue(q.DictionaryKey)
            }).ToList();
            model.AdministrativeFilter.Insert(0, new FilterItem()
            {
                Id = 0, DisplayText = _umbracoHelper.GetDictionaryValue("Notices.Placeholder.AllAdministrative")
            });

            model.StatusFilter = Enum.GetValues(typeof(NoticesSalesStatusEnum)).Cast <NoticesSalesStatusEnum>().Select(q => new FilterItem()
            {
                Id = (int)q, DisplayText = _umbracoHelper.GetDictionaryValue(string.Format("Advertising.Placeholder.{0}", q))
            }).ToList();
            model.StatusFilter.Insert(0, new FilterItem()
            {
                Id = 0, DisplayText = _umbracoHelper.GetDictionaryValue("Notices.Placeholder.Any")
            });

            model.LawActFilter = Enum.GetValues(typeof(NoticesLawActEnum)).Cast <NoticesLawActEnum>().Select(q => new FilterItem()
            {
                Id = (int)q, DisplayText = _umbracoHelper.GetDictionaryValue(string.Format("Notices.LawAct.Placeholder.{0}", q))
            }).ToList();
            model.LawActFilter.Insert(0, new FilterItem()
            {
                Id = 0, DisplayText = _umbracoHelper.GetDictionaryValue("Notices.Placeholder.Any")
            });

            model.TypeOfContractFilter = Enum.GetValues(typeof(NoticesTypeOfContractEnum)).Cast <NoticesTypeOfContractEnum>().Select(q => new FilterItem()
            {
                Id = (int)q, DisplayText = _umbracoHelper.GetDictionaryValue(string.Format("Notices.TypeOfContract.Placeholder.{0}", q))
            }).ToList();
            model.TypeOfContractFilter.Insert(0, new FilterItem()
            {
                Id = 0, DisplayText = _umbracoHelper.GetDictionaryValue("Notices.Placeholder.Any")
            });

            #region SetFIlterStateCookie

            var _filterModel = new ContractsFilterStateModel()
            {
                SelectedStatusId         = model.SelectedStatusId,
                SelectedAdministrativeId = model.SelectedAdministrativeId,
                Name                     = model.Name,
                Number                   = model.Number,
                StartDate                = model.StartDate,
                EndDate                  = model.EndDate,
                SelectedLawActId         = model.SelectedLawActId,
                SelectedTypeOfContractId = model.SelectedTypeOfContractId
            };
            CookiesExtensions.CreateCookie(CookieVariables.ContractsFilterCookie, StringExtensions.Base64Encode(JsonConvert.SerializeObject(_filterModel)));
            #endregion
            #endregion

            if (model.SelectedAdministrativeId != 0)
            {
                _noticesList = _noticesList.Where(q => q.Administrative.SavedValue != null && JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(q.Administrative.SavedValue.ToString()).Any(c => c.Key == model.SelectedAdministrativeId.ToString()));
            }
            if (model.SelectedStatusId != 0)
            {
                _noticesList = _noticesList.Where(q => ((int)q.GetStatus()) == model.SelectedStatusId);
            }
            if (model.SelectedLawActId != 0)
            {
                _noticesList = _noticesList.Where(q => q.LawAct.SavedValue != null && JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(q.LawAct.SavedValue.ToString()).Any(c => c.Key == model.SelectedLawActId.ToString()));
            }
            if (model.SelectedTypeOfContractId != 0)
            {
                _noticesList = _noticesList.Where(q => q.TypeOfContract.SavedValue != null && JsonConvert.DeserializeObject <IEnumerable <NuPickersSqlDropDownPicker> >(q.TypeOfContract.SavedValue.ToString()).Any(c => c.Key == model.SelectedTypeOfContractId.ToString()));
            }
            if (!string.IsNullOrEmpty(model.Name))
            {
                _noticesList = _noticesList.Where(q => q.Name.Trim().ToLower().Contains(model.Name.Trim().ToLower()));
            }
            if (!string.IsNullOrEmpty(model.Number))
            {
                _noticesList = _noticesList.Where(q => q.NumberOfProceedings.Trim().ToLower().Contains(model.Number.Trim().ToLower()));
            }
            if (model.StartDate.HasValue && model.EndDate.HasValue)
            {
                _noticesList = _noticesList.Where(q => q.InitiationOfProceedingsDate >= model.StartDate.Value && q.InitiationOfProceedingsDate <= model.EndDate.Value);
            }
            else if (model.StartDate.HasValue && !model.EndDate.HasValue)
            {
                _noticesList = _noticesList.Where(q => q.InitiationOfProceedingsDate >= model.StartDate.Value);
            }
            else if (!model.StartDate.HasValue && model.EndDate.HasValue)
            {
                _noticesList = _noticesList.Where(q => q.InitiationOfProceedingsDate <= model.EndDate.Value);
            }
            model.AllNewsCount = _noticesList.Count();
            model.NoticesList  = _noticesList.OrderByDescending(q => q.InitiationOfProceedingsDate).Take(model.DisplayCount).Select(q => new NoticeBoxModel(q));
            return(model);
        }