コード例 #1
0
        public virtual ActionResult GetCasino(AdministrativeDivision city, Casino casino)
        {
            SetNavigationHierarchy(GetCityCasinoNavigationItems(city, casino));

            var showDeleteCasinoLink = SecurityUser.HasRight(RightType.DeleteCasino, city);
            var showEditCasinoLink = SecurityUser.HasRight(RightType.EditCasino, city);
            var showAddSuspensionLink = SecurityUser.HasRight(RightType.AddSuspensions, city);

            var excemptionsTexts = new List<string>();
            foreach (var suspension in casino.Suspensions)
            {
                var excemptionText = String.Empty;
                for (var i = 0; i < suspension.Exemptions.Count; i++)
                {
                    var exemption = suspension.Exemptions[i];
                    excemptionText += exemption.Quantity + " " + _exemptionItemTypeLocalizator.Localize(exemption.ItemType, exemption.Quantity);
                    if (i != suspension.Exemptions.Count - 1)
                        excemptionText += ", ";
                }
                excemptionsTexts.Add(excemptionText);
            }

            var getCasinoViewModel = new GetCasinoViewModel(casino, excemptionsTexts, showDeleteCasinoLink, showEditCasinoLink, showAddSuspensionLink);

            return View(getCasinoViewModel);
        }
コード例 #2
0
        public virtual ActionResult AddWitness(AdministrativeDivision city)
        {
            SetNavigationHierarchy(GetGamblingCityNavigationItems(city), "Записаться в понятые");

            var addWitnessFormViewModel = new AddWitnessFormViewModel();

            return View(addWitnessFormViewModel);
        }
コード例 #3
0
        public virtual ActionResult AddConfidentialInformation(AdministrativeDivision city)
        {
            SetNavigationHierarchy(GetGamblingCityNavigationItems(city), "Предоставить конфиденциальную информацию");

            var confidentialInformationFormViewModel = new AddConfidentialInformationFormViewModel();

            return View(confidentialInformationFormViewModel);
        }
コード例 #4
0
        public virtual ActionResult GetSalePoint(AdministrativeDivision city, DrugsSalePoint salePoint)
        {
            SetNavigationHierarchy(GetDrugsLocationSalePointsNavigationItems(city), salePoint.Address);

            var getSalePointViewModel = new GetSalePointViewModel(salePoint);

            return View(getSalePointViewModel);
        }
コード例 #5
0
 public virtual ActionResult AddWitness(AdministrativeDivision city, AddWitnessFormViewModel form)
 {
     return Handle(() =>
                {
                    var witnessForm = new Witness(city.Id, form.Name, form.ConnectText, form.WhenText);
                    _documentSession.Store(witnessForm);
                },
                success: () => MVC.Gambling.Casino.GetCasinos());
 }
コード例 #6
0
 public GetCasinosViewModel(AdministrativeDivision administrativeDivision, IEnumerable<Data.Model.Casino> casinos, string cityCasinosRssTitle, bool showGetWitnessesLink, bool showGetConfidentialInformationsLink, bool showCasinoStatusAsLink)
 {
     AdministrativeDivision = administrativeDivision;
     Casinos = casinos;
     CityCasinosRssTitle = cityCasinosRssTitle;
     ShowGetWitnessesLink = showGetWitnessesLink;
     ShowGetConfidentialInformationsLink = showGetConfidentialInformationsLink;
     ShowCasinoStatusAsLink = showCasinoStatusAsLink;
 }
コード例 #7
0
 public virtual ActionResult AddConfidentialInformation(AdministrativeDivision city, AddConfidentialInformationFormViewModel form)
 {
     return Handle(() =>
                       {
                           var confidentialInformationForm = new ConfidentialInformation(
                               city.Id, form.Name, form.ConnectText, form.ConfidentialInformationText);
                           _documentSession.Store(confidentialInformationForm);
                       },
                       success: () => MVC.Gambling.Casino.GetCasinos());
 }
コード例 #8
0
ファイル: CityController.cs プロジェクト: alexidsa/civildoit
        public virtual ActionResult AddCity(AddCityFormViewModel form)
        {
            return Handle(() =>
                              {
                                  if (!HasRight(RightType.AddCities))
                                      throw new SecurityAccessDeniedException();

                                  var city = new AdministrativeDivision(null, form.Name, form.Alias, form.Latitude, form.Longitude);
                                  _documentSession.Store(city);
                              });
        }
コード例 #9
0
        public virtual ActionResult GetSalePoints(AdministrativeDivision city)
        {
            SetNavigationHierarchy(GetDrugsLocationSalePointsNavigationItems(city));

            var drugsSalePoints = _documentSession.Query<DrugsSalePoint>().
                Where(x => x.Id == city.Id).
                OrderByDescending(x => x.AdditionDate).
                ToList();

            var indexViewModel = new GetSalePointsViewModel(city, drugsSalePoints);

            return View(indexViewModel);
        }
コード例 #10
0
        public virtual ActionResult GetWitnesses(AdministrativeDivision city)
        {
            if (!SecurityUser.HasRight(RightType.WatchWitnesses, city)) 
                return RedirectToAction(MVC.Home.Index());

            SetNavigationHierarchy(GetGamblingCityNavigationItems(city), "Список понятых");

            var witnesses = _documentSession.Query<Witness>().
                Where(w => w.CityId == city.Id).
                OrderByDescending(w => w.DateTime).
                ToList();

            return View(witnesses);
        }
コード例 #11
0
        public virtual ActionResult GetConfidentialInformations(AdministrativeDivision city)
        {
            if (!SecurityUser.HasRight(RightType.WatchConfidentialInformation, city))
                return RedirectToAction(MVC.Home.Index());

            SetNavigationHierarchy(GetGamblingCityNavigationItems(city), "Конфиденциальная информация");

            var confidentialInformations =
                _documentSession.Query<ConfidentialInformation>().
                Where(ci => ci.CityId == city.Id).
                OrderByDescending(ci => ci.DateTime).ToList();

            return View(confidentialInformations);
        }
コード例 #12
0
        public virtual ActionResult AddSalePoint(AdministrativeDivision city, AddSalePointFormViewModel form)
        {
            DrugsSalePoint salePoint = null;

            return Handle(() =>
                              {
                                  var geoPoint = _yandexGeolocationService.GetPoint(city.Name, form.Address);

                                  salePoint = new DrugsSalePoint(city.Id, form.Address, geoPoint, form.Description);

                                  _documentSession.Store(salePoint);
                              },
                              success: () => MVC.Drugs.SalePoint.GetSalePoint(city, salePoint));
        }
コード例 #13
0
        public virtual ActionResult GetCommentsFeed(AdministrativeDivision city)
        {
            var lastComments = _documentSession.Query<DrugsSalePointsCommentsIndex.IndexResult, DrugsSalePointsCommentsIndex>().
                Where(x => x.AdministrativeDivisionId == city.Id).
                OrderByDescending(x => x.DateTime).
                Take(10).
                AsProjection<DrugsSalePointsCommentsIndex.IndexResult>().
                ToList();

            var getCommentsFeedViewModels = lastComments.Select(
                x => new GetCommentsFeedViewModel(MVC.Drugs.SalePoint.GetSalePoint(city, new DrugsSalePoint() { Id = x.SalePointId }),
                                                  x.CommentId.GetNumericPart(), x.DateTime, x.Author, x.Text)).
                ToList();

            return View(MVC.Shared.Views.GetCommentsFeed, getCommentsFeedViewModels);
        }
コード例 #14
0
        public virtual ActionResult GetCasinos(AdministrativeDivision city)
        {
            SetNavigationHierarchy(GetGamblingCityCasinosNavigationItems(city));

            var showGetWitnessesLink = SecurityUser.HasRight(RightType.WatchWitnesses, city);
            var showGetConfidentialInformationsLink = SecurityUser.HasRight(RightType.WatchConfidentialInformation, city);
            var showCasinoStatusAsLink = SecurityUser.HasRight(RightType.EditCasinoStatus, city);
            var cityCasinosRssTitle = GetCityCasinosRssTitle(city);

            var casinos = _documentSession.Query<Casino>().
                Where(x => x.CityId == city.Id).
                OrderBy(x => x.Address).
                ToList();

            var getCasinosViewModel = new GetCasinosViewModel(city, casinos, cityCasinosRssTitle, showGetWitnessesLink, showGetConfidentialInformationsLink, showCasinoStatusAsLink);

            return View(getCasinosViewModel);
        }
コード例 #15
0
 private string GetCityCasinosRssTitle(AdministrativeDivision city)
 {
     return string.Format("{0}. Нелегальные игорные заведения, пресечения их деятельности и комментарии", city.Name);
 }
コード例 #16
0
        public virtual ActionResult Rss(AdministrativeDivision city)
        {
            var casinosRssItems = _documentSession.Query<CasinosRssIndex.IndexResult, CasinosRssIndex>().
                Where(x => x.CityId == city.Id).
                OrderByDescending(x => x.DateTime).
                Take(10).
                AsProjection<CasinosRssIndex.IndexResult>().
                ToList();

            var syndicationItems = casinosRssItems.Select(
                x =>
                {
                    string title;
                    string content;
                    string url;
                    string id;
                    switch (x.ItemType)
                    {
                        case CasinosRssIndex.ItemType.Casino:
                            title = string.Format("Добавлено казино", x.CasinoAddress);
                            content = string.Format("Адрес: {0}, название: {1}", x.CasinoAddress, x.CasinoTitle);
                            url = Url.Action(MVC.Gambling.Casino.GetCasino(city, new Casino() { Id = x.CasinoId }), Request.Url.Scheme);
                            id = "casino" + x.CasinoId.GetNumericPart();
                            break;
                        case CasinosRssIndex.ItemType.Suspension:
                            title = string.Format("Пресечение деятельности казино по адресу {0}", x.CasinoAddress);
                            content = "Изъято: " + _exemptionsService.GetExemptionsString(x.Exemptions);
                            url = Url.Action(MVC.Gambling.Casino.GetCasino(city, new Casino() { Id = x.CasinoId }), Request.Url.Scheme) + "#suspension" + x.ChildId.GetNumericPart();
                            id = "casinosuspension" + x.ChildId.GetNumericPart();
                            break;
                        case CasinosRssIndex.ItemType.Comment:
                            title = string.Format("Комментарий к казино по адресу {0}", x.CasinoAddress);
                            content = x.CommentText;
                            url = Url.Action(MVC.Gambling.Casino.GetCasino(city, new Casino() { Id = x.CasinoId }), Request.Url.Scheme) + "#comment" + x.ChildId.GetNumericPart();
                            id = "casinocomment" + x.ChildId.GetNumericPart();
                            break;
                        default:
                            throw new ArgumentOutOfRangeException("ItemType");
                    }

                    var syndicationItem = new SyndicationItem(title, content, new Uri(url), id, x.DateTime);

                    if (x.Author != null)
                        syndicationItem.Authors.Add(new SyndicationPerson(null, x.Author, null));

                    return syndicationItem;
                }).
                ToList();

            var syndicationFeed = new SyndicationFeed(GetCityCasinosRssTitle(city), null, new Uri(Url.Action(MVC.Gambling.Casino.Rss(city), Request.Url.Scheme)), syndicationItems);

            return new FeedResult(new Atom10FeedFormatter(syndicationFeed));
        }
コード例 #17
0
        public virtual ActionResult GetSuspensionsFeed(AdministrativeDivision city)
        {
            var suspensions = _documentSession.Query<CasinosSuspensionsIndex.IndexResult, CasinosSuspensionsIndex>().
                Where(x => x.CityId == city.Id).
                OrderByDescending(x => x.DateTime).
                Take(10).
                AsProjection<CasinosSuspensionsIndex.IndexResult>().
                ToList();

            var excemptionsTexts = suspensions.Select(suspension => _exemptionsService.GetExemptionsString(suspension.Exemptions)).ToList();

            var getSuspensionsFeedViewModel = new GetSuspensionsFeedViewModel(city, suspensions, excemptionsTexts);

            return View(getSuspensionsFeedViewModel);
        }
コード例 #18
0
        public virtual ActionResult AddSuspension(AdministrativeDivision city, Casino casino, AddSuspensionFormViewModel form)
        {
            return Handle(() =>
                              {
                                  if (!SecurityUser.HasRight(RightType.AddSuspensions, city))
                                      throw new SecurityAccessDeniedException();

                                  //ToDo: Move it to ModelBinder
                                  var suspensionDate = DateTime.ParseExact(
                                      form.DateString, FrontendConstants.DateFormat, CultureInfo.CurrentCulture);

                                  var exemptions = new List<Exemption>();
                                  //ToDo: Move this stuff to ModelBinder
                                  foreach (var exemptionViewModel in form.Exemptions)
                                  {
                                      if (exemptionViewModel.ItemType == 0 || exemptionViewModel.Quantity < 1)
                                          continue;
                                      var exemption = new Exemption(exemptionViewModel.ItemType,
                                                                    exemptionViewModel.Quantity);
                                      exemptions.Add(exemption);
                                  }
                                  var suspension = new Suspension(suspensionDate, exemptions);
                                  suspension.Id = _documentStore.Conventions.GenerateDocumentKey(suspension);
                                  casino.Suspensions.Add(suspension);

                                  _documentSession.Store(casino);
                              },
                              success: () => Actions.GetCasino(city, casino));
        }
コード例 #19
0
        public virtual ActionResult AddCasino(AdministrativeDivision city, AddCasinoFormViewModel form)
        {
            Casino casino = null;
            return Handle(() =>
            {
                var geoPoint = _yandexGeolocationService.GetPoint(city.Name, form.Address);

                casino = new Casino(city.Id, form.Address, geoPoint, form.Name);
                _documentSession.Store(casino);
            },
            success: () => Actions.GetCasino(city, casino));
        }
コード例 #20
0
        public virtual ActionResult EditCasino(AdministrativeDivision city, Casino casino)
        {
            if (!SecurityUser.HasRight(RightType.EditCasino, city))
                return RedirectToAction(MVC.Home.Index());

            SetNavigationHierarchy(GetCityCasinoNavigationItems(city, casino), "123");

            var editCasinoViewModel = new EditCasinoViewModel(casino);

            return View(editCasinoViewModel);
        }
コード例 #21
0
ファイル: Fixes.cs プロジェクト: alexidsa/civildoit
        //[Fact]
        public void AddAdministrativeDivisions()
        {
            var documentStore = new DocumentStore()
            {
                ConnectionStringName = "Secure",
                Conventions =
                {
                    DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites,
                    FindTypeTagName = type =>
                    {
                        if (typeof(Initiative).IsAssignableFrom(type))
                            return "Initiatives";
                        return DocumentConvention.DefaultTypeTagName(type);
                    }
                },
            };
            documentStore.Initialize();
            var documentSession = documentStore.OpenSession();

            var tomskayaOblast = new AdministrativeDivision(null, "Томская область", "tomskayaoblast", 0, 0);
            documentSession.Store(tomskayaOblast);

            var tomsk = new AdministrativeDivision(tomskayaOblast.Id, "Томск", "tomsk", 84.955505, 56.49149);
            documentSession.Store(tomsk);

            var seversk = new AdministrativeDivision(tomskayaOblast.Id, "Северск", "seversk", 84.913963, 56.599875);
            documentSession.Store(seversk);

            documentSession.SaveChanges();
        }
コード例 #22
0
        public virtual ActionResult AddSalePoint(AdministrativeDivision city)
        {
            SetNavigationHierarchy(GetDrugsLocationSalePointsNavigationItems(city), "Добавить");

            return View(new AddSalePointFormViewModel());
        }
コード例 #23
0
ファイル: User.cs プロジェクト: alexidsa/civildoit
 public bool HasRight(RightType rightType, AdministrativeDivision administrativeDivision)
 {
     return HasRight(rightType, administrativeDivision.Id, null);
 }
コード例 #24
0
 private IEnumerable<NavigationItem> GetCityCasinoNavigationItems(AdministrativeDivision city, Casino casino)
 {
     return new List<NavigationItem>(GetGamblingCityCasinosNavigationItems(city))
                {
                    new NavigationItem(casino.Address, MVC.Gambling.Casino.GetCasino(city, casino))
                };
 }
コード例 #25
0
        public virtual ActionResult EditCasino(AdministrativeDivision city, Casino casino, EditCasinoFormViewModel form)
        {
            return Handle(() =>
                              {
                                  if (!SecurityUser.HasRight(RightType.EditCasino, city))
                                      throw new SecurityAccessDeniedException();

                                  casino.Address = form.Address;
                                  casino.Title = form.Title;

                                  _documentSession.Store(casino);
                              },
                              success: () => Actions.GetCasino(city, casino));
        }
コード例 #26
0
        //ToDo: Replace by HttpPost
        public virtual ActionResult SwitchCasinoStatus(AdministrativeDivision city, Casino casino)
        {
            return Handle(() =>
                              {
                                  if (!SecurityUser.HasRight(RightType.EditCasinoStatus, city))
                                      throw new SecurityAccessDeniedException();

                                  if (casino.Status == CasinoStatus.Opened)
                                      casino.Status = CasinoStatus.Closed;
                                  else if (casino.Status == CasinoStatus.Closed)
                                      casino.Status = CasinoStatus.Opened;

                                  _documentSession.Store(casino);
                              });
        }
コード例 #27
0
        public virtual ActionResult AddCasino(AdministrativeDivision city)
        {
            SetNavigationHierarchy(GetGamblingCityCasinosNavigationItems(city), "Добавить");

            return View(new AddCasinoFormViewModel());
        }
コード例 #28
0
        public virtual ActionResult AddSuspension(AdministrativeDivision city, Casino casino)
        {
            if (!SecurityUser.HasRight(RightType.AddSuspensions, city))
                return RedirectToAction(MVC.Home.Index());

            SetNavigationHierarchy(GetCityCasinoNavigationItems(city, casino), "Добавить пресечение");

            var exemptionItemTypes = new List<SelectListItem>();
            exemptionItemTypes.Add(new SelectListItem() { Text = "Выбрать...", Value = "0" });
            foreach (ExemptionItemType exemptionItemType in Enum.GetValues(typeof(ExemptionItemType)))
            {
                var selectListItem = new SelectListItem()
                {
                    Value = ((long)exemptionItemType).ToString(),
                    Text = _exemptionItemTypeDropDownListLocalizator.Localize(exemptionItemType)
                };
                exemptionItemTypes.Add(selectListItem);
            }

            var exemptions = new List<ExemptionFormViewModel>();
            for (var exemptionIndex = 0; exemptionIndex < 3; exemptionIndex++)
            {
                exemptions.Add(new ExemptionFormViewModel());
            }

            var addSuspensionViewModel = new AddSuspensionFormViewModel(exemptions);

            return View(addSuspensionViewModel);
        }
コード例 #29
0
        //ToDo: This action should be executed as post
        public virtual ActionResult DeleteCasino(AdministrativeDivision city, Casino casino)
        {
            return Handle(() =>
                              {
                                  if (!SecurityUser.HasRight(RightType.DeleteCasino, city))
                                      throw new SecurityAccessDeniedException();

                                  _documentSession.Advanced.DatabaseCommands.Delete(casino.Id, null);
                              },
                              success: () => MVC.Gambling.Casino.GetCasinos());
        }
コード例 #30
0
 public GetSuspensionsFeedViewModel(AdministrativeDivision administrativeDivision, IEnumerable<CasinosSuspensionsIndex.IndexResult> suspensions, IList<string> exemptionsTexts)
 {
     AdministrativeDivision = administrativeDivision;
     Suspensions = suspensions;
     ExemptionsTexts = exemptionsTexts;
 }