Пример #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 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));
        }
Пример #3
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));
        }
Пример #4
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))
                };
 }
Пример #5
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);
        }
Пример #6
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);
                              });
        }
Пример #7
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));
        }
Пример #8
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);
        }
Пример #9
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());
        }