Esempio n. 1
0
        public ActionResult Create(int entityId, LogicaName logicalName, int?seasonId)
        {
            ViewBag.Leagues = logicalName == LogicaName.Union && seasonId.HasValue ?
                              _leagueRepo.GetLeaguesBySesonUnion(entityId, seasonId.Value) :
                              null;

            var model = new CreateSeason
            {
                EntityId = entityId,
                RelevantEntityLogicalName = logicalName
            };

            return(PartialView("_CreateSeason", model));
        }
Esempio n. 2
0
        public HttpResult Post(CreateSeason request)
        {
            var season = new Season().PopulateWith(request.SanitizeDtoHtml());
            var newId = Db.Insert(season, selectIdentity: true);

            return new HttpResult(new SeasonResponse {Season = Get(new FetchSeason {Id = (int) newId}).Season})
            {
                StatusCode = HttpStatusCode.Created,
                Headers =
                {
                    {HttpHeaders.Location, Request.AbsoluteUri.CombineWith(newId)}
                }
            };
        }
Esempio n. 3
0
        public ActionResult Create(CreateSeason model)
        {
            if (ModelState.IsValid)
            {
                var newSeason = new Season
                {
                    Name        = model.Name,
                    StartDate   = model.StartDate.Value,
                    EndDate     = model.EndDate.Value,
                    Description = model.Description
                };

                switch (model.RelevantEntityLogicalName)
                {
                case LogicaName.Union:
                    newSeason.UnionId = model.EntityId;

                    var lastSeasonId = _seasonsRepository.GetLastSeasonByCurrentUnionId(model.EntityId);
                    _seasonsRepository.Create(newSeason);
                    _seasonsRepository.Save();

                    var leaguesToDuplicate = model.Leagues;
                    if (model.IsDuplicate != null && model.IsDuplicate.Value)
                    {
                        _seasonsRepository.Duplicate(leaguesToDuplicate, lastSeasonId, newSeason.Id);
                        _seasonsRepository.Save();
                    }

                    return(RedirectToAction("Edit", "Unions", new { id = model.EntityId }));

                case LogicaName.Club:
                    newSeason.ClubId = model.EntityId;

                    _seasonsRepository.Create(newSeason);
                    _seasonsRepository.Save();

                    return(RedirectToAction("Edit", "Clubs", new { id = model.EntityId }));
                }
            }

            return(PartialView("_CreateSeason", model));
        }