public IActionResult Create()
        {
            var countries = _db.Countries.OrderBy(c => c.Name)
                            .Select(x => new { Id = x.Id, Value = x.Name });
            var country = new AddLeagueModel();

            country.CountryList = new SelectList(countries, "Id", "Value");



            return(View(country));
        }
示例#2
0
        public LeagueModel AddLeague(AddLeagueModel model)
        {
            var command = $@"
INSERT INTO League(
    TypeId,
    Iteration,
    StartDate,
    EndDate,
    IsCompleted,
    Title)
OUTPUT Inserted.Id
VALUES(
    @TypeId,
    @Iteration,
    @StartDate,
    @EndDate,
    @IsCompleted,
    @Title)";

            var result = ExecCommandScaler <long>(command, model);

            if (result != 0)
            {
                return new LeagueModel
                       {
                           Id          = result,
                           TypeId      = model.TypeId,
                           Iteration   = model.Iteration,
                           StartDate   = model.StartDate,
                           EndDate     = model.EndDate,
                           IsCompleted = model.IsCompleted,
                           Title       = model.Title
                       }
            }
            ;

            return(null);
        }
        public async Task <IActionResult> AddLeague(AddLeagueModel model, IFormCollection LeagueImage)
        {
            //var webRoot = _environment.WebRootPath;
            //string leagueId = Convert.ToString(LeagueImage["Id"]);
            string storePath = "/images/leagues/";
            var    path      = Path.Combine(
                Directory.GetCurrentDirectory(), "wwwroot", "images", "leagues",
                LeagueImage.Files[0].FileName);

            using (var stream = new FileStream(path, FileMode.Create))
            {
                await LeagueImage.Files[0].CopyToAsync(stream);
            }

            var league = new Leagues
            {
                LeagueName     = model.LeagueName,
                CountryId      = model.CountryId,
                LeagueImageUrl = storePath + model.LeagueImage.FileName
            };
            await _leagueService.Create(league);

            return(RedirectToAction("Index", "Leagues"));
        }
示例#4
0
 public LeagueModel AddLeague(AddLeagueModel model)
 {
     return(_leagueLib.AddLeague(model));
 }