Пример #1
0
    public async Task <ActionResult> Create(string clubInitials, Season model)
    {
        try
        {
            var clubId = (await _clubService.GetClubId(clubInitials));
            if (!await _authService.CanUserEdit(User, clubId))
            {
                return(Unauthorized());
            }
            model.ClubId = clubId;

            var errors = await _seasonService.GetSavingSeasonErrors(model);

            foreach (var error in errors)
            {
                ModelState.AddModelError(String.Empty, error);
            }
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            await _seasonService.SaveNew(model);

            return(RedirectToAction("Index", "Admin"));
        }
        catch
        {
            ModelState.AddModelError(String.Empty, "An error occurred saving these changes.");
            return(View(model));
        }
    }
Пример #2
0
    public async Task <ActionResult> Create(
        string clubInitials,
        BoatClass model)
    {
        try
        {
            var clubId = await _clubService.GetClubId(clubInitials);

            if (!await _authService.CanUserEdit(User, clubId))
            {
                return(Forbid());
            }
            model.ClubId = clubId;
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            await _classService.SaveNew(model);

            return(RedirectToAction("Index", "Admin"));
        }
        catch
        {
            ModelState.AddModelError(String.Empty,
                                     "An error occurred saving these changes.");
            return(View(model));
        }
    }
Пример #3
0
    // GET: Admin
    public async Task <ActionResult> Index(string clubInitials)
    {
        ViewData["ClubInitials"] = clubInitials;
        if (!await _authService.CanUserEdit(User, clubInitials))
        {
            return(Unauthorized());
        }
        var vm = await _adminService.GetClub(clubInitials);

        _tipService.AddTips(ref vm);
        return(View(vm));
    }
Пример #4
0
    public async Task <ActionResult> Create(
        string clubInitials,
        AnnouncementWithOptions model,
        string returnUrl = null)
    {
        ViewData["ReturnUrl"] = returnUrl;
        try
        {
            var clubId = await _clubService.GetClubId(clubInitials);

            if (!await _authService.CanUserEdit(User, clubId))
            {
                return(Unauthorized());
            }
            model.ClubId = clubId;
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.Content   = _sanitizer.Sanitize(model.Content);
            model.CreatedBy = await GetUserStringAsync();

            model.CreatedDate      = DateTime.UtcNow;
            model.CreatedLocalDate = DateTime.UtcNow.AddMinutes(0 - model.TimeOffset);
            await _announcementService.SaveNew(model);

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            return(RedirectToAction("Index", "Admin"));
        }
        catch
        {
            AnnouncementWithOptions vm;
            if (model.RegattaId.HasValue)
            {
                vm = await _announcementService.GetBlankAnnouncementForRegatta(
                    clubInitials,
                    model.RegattaId.Value);
            }
            else
            {
                vm = model;
            }
            return(View(vm));
        }
    }
    public async Task <ActionResult> Options(string clubInitials)
    {
        var clubId = await _clubService.GetClubId(clubInitials);

        if (!await _authService.CanUserEdit(User, clubId))
        {
            return(Unauthorized());
        }
        IList <Core.Model.Competitor> competitors = await _competitorService.GetCompetitorsAsync(clubId, false);

        var vm = new MergeCompetitorViewModel
        {
            TargetCompetitorOptions = competitors.OrderBy(c => c.Name).ToList()
        };

        return(View("SelectTarget", vm));
    }
Пример #6
0
    public async Task <ActionResult> Create(
        string clubInitials,
        FleetWithOptionsViewModel model,
        string returnUrl = null)
    {
        ViewData["ReturnUrl"] = returnUrl;
        try
        {
            var clubId = await _clubService.GetClubId(clubInitials);

            if (!await _authService.CanUserEdit(User, clubId))
            {
                return(Unauthorized());
            }
            model.ClubId = clubId;
            if (!ModelState.IsValid)
            {
                var vmOptions = await _fleetService.GetBlankFleetWithOptionsAsync(
                    clubInitials,
                    model.RegattaId);

                model.BoatClassOptions           = vmOptions.BoatClassOptions;
                model.CompetitorOptions          = vmOptions.CompetitorOptions;
                model.CompetitorBoatClassOptions = vmOptions.CompetitorBoatClassOptions;

                return(View(model));
            }
            await _fleetService.SaveNew(model);

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            return(RedirectToAction("Index", "Admin"));
        }
        catch
        {
            var vm = await _fleetService.GetBlankFleetWithOptionsAsync(
                clubInitials,
                model.RegattaId);

            model.BoatClassOptions = vm.BoatClassOptions;
            return(View(model));
        }
    }
Пример #7
0
    public async Task <ActionResult> Add(
        string clubInitials,
        UserViewModel model,
        string returnUrl = null)
    {
        ViewData["ReturnUrl"] = returnUrl;
        try
        {
            var clubId = await _clubService.GetClubId(clubInitials);

            if (!await _authService.CanUserEdit(User, clubId))
            {
                return(Unauthorized());
            }
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            model.CreatedBy = await GetUserStringAsync();

            model.Created = DateTime.UtcNow;
            await _permissionService.UpdatePermission(clubId, model);

            if (!string.IsNullOrWhiteSpace(returnUrl))
            {
                return(Redirect(returnUrl));
            }
            return(Redirect(Url.RouteUrl(new {
                controller = "Admin",
                action = "Index"
            }) + "#scorekeepers"));
        }
        catch
        {
            ModelState.AddModelError(String.Empty, "An error has occurred.");
            return(View(model));
        }
    }
Пример #8
0
    // GET: Competitor
    public async Task <ActionResult> Index(string clubInitials)
    {
        var canEdit = await _authService.CanUserEdit(User, clubInitials);

        var competitors = await _competitorService
                          .GetCompetitorsWithDeletableInfoAsync(clubInitials, canEdit);

        var vm = new ClubCollectionViewModel <CompetitorIndexViewModel>
        {
            ClubInitials = clubInitials,
            List         = competitors,
            CanEdit      = await _authService.CanUserEdit(User, clubInitials)
        };

        return(View(vm));
    }
Пример #9
0
    public async Task <ActionResult> Index(string clubInitials)
    {
        ViewData["ClubInitials"] = clubInitials;

        var regattas = await _regattaService.GetAllRegattaSummaryAsync(clubInitials);

        var clubName = await _clubService.GetClubName(clubInitials);

        return(View(new ClubCollectionViewModel <RegattaSummaryViewModel>
        {
            List = regattas,
            ClubInitials = clubInitials,
            ClubName = clubName,
            CanEdit = await _authService.CanUserEdit(User, clubInitials)
        }));
    }
Пример #10
0
    public async Task <ActionResult> Index(string clubInitials)
    {
        ViewData["ClubInitials"] = clubInitials.ToUpperInvariant();

        var series = await _seriesService.GetNonRegattaSeriesSummariesAsync(clubInitials);

        var clubName = await _clubService.GetClubName(clubInitials);

        return(View(new ClubCollectionViewModel <SeriesSummary>
        {
            List = series,
            ClubInitials = clubInitials,
            ClubName = clubName,
            CanEdit = await _authService.CanUserEdit(User, clubInitials)
        }));
    }
Пример #11
0
    public async Task <ActionResult> Index(
        string clubInitials,
        string seasonName,
        bool showScheduled = true,
        bool showAbandoned = true)
    {
        var capInitials = clubInitials.ToUpperInvariant();

        if (String.IsNullOrWhiteSpace(seasonName))
        {
            var currentSeason = await _raceService.GetCurrentSeasonAsync(capInitials);

            if (currentSeason != null)
            {
                return(RedirectToRoute("Race", new
                {
                    clubInitials = capInitials,
                    seasonName = currentSeason.UrlName
                }));
            }
        }
        var clubName = await _clubService.GetClubName(capInitials);

        var races = await _raceService.GetAllRaceSummariesAsync(
            capInitials,
            seasonName,
            showScheduled,
            showAbandoned);

        return(View(new ClubItemViewModel <RaceSummaryListViewModel>
        {
            Item = races,
            ClubInitials = capInitials,
            ClubName = clubName,
            CanEdit = await _authService.CanUserEdit(User, capInitials)
        }));
    }