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); }
public virtual ActionResult AddWitness(AdministrativeDivision city) { SetNavigationHierarchy(GetGamblingCityNavigationItems(city), "Записаться в понятые"); var addWitnessFormViewModel = new AddWitnessFormViewModel(); return View(addWitnessFormViewModel); }
public virtual ActionResult AddConfidentialInformation(AdministrativeDivision city) { SetNavigationHierarchy(GetGamblingCityNavigationItems(city), "Предоставить конфиденциальную информацию"); var confidentialInformationFormViewModel = new AddConfidentialInformationFormViewModel(); return View(confidentialInformationFormViewModel); }
public virtual ActionResult GetSalePoint(AdministrativeDivision city, DrugsSalePoint salePoint) { SetNavigationHierarchy(GetDrugsLocationSalePointsNavigationItems(city), salePoint.Address); var getSalePointViewModel = new GetSalePointViewModel(salePoint); return View(getSalePointViewModel); }
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()); }
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; }
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()); }
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); }); }
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); }
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); }
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); }
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)); }
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); }
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); }
private string GetCityCasinosRssTitle(AdministrativeDivision city) { return string.Format("{0}. Нелегальные игорные заведения, пресечения их деятельности и комментарии", city.Name); }
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)); }
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); }
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)); }
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)); }
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); }
//[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(); }
public virtual ActionResult AddSalePoint(AdministrativeDivision city) { SetNavigationHierarchy(GetDrugsLocationSalePointsNavigationItems(city), "Добавить"); return View(new AddSalePointFormViewModel()); }
public bool HasRight(RightType rightType, AdministrativeDivision administrativeDivision) { return HasRight(rightType, administrativeDivision.Id, null); }
private IEnumerable<NavigationItem> GetCityCasinoNavigationItems(AdministrativeDivision city, Casino casino) { return new List<NavigationItem>(GetGamblingCityCasinosNavigationItems(city)) { new NavigationItem(casino.Address, MVC.Gambling.Casino.GetCasino(city, casino)) }; }
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)); }
//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); }); }
public virtual ActionResult AddCasino(AdministrativeDivision city) { SetNavigationHierarchy(GetGamblingCityCasinosNavigationItems(city), "Добавить"); return View(new AddCasinoFormViewModel()); }
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); }
//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()); }
public GetSuspensionsFeedViewModel(AdministrativeDivision administrativeDivision, IEnumerable<CasinosSuspensionsIndex.IndexResult> suspensions, IList<string> exemptionsTexts) { AdministrativeDivision = administrativeDivision; Suspensions = suspensions; ExemptionsTexts = exemptionsTexts; }