예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,Name,Description,LogoPath")] League league, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                league.LogoPath = "~/uploads/" + logoFolder + "/" + file.FileName.Trim();
                _upload.UploadFile(file, logoFolder);
                _context.Add(league);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(league));
        }
        public async Task <IActionResult> Create([Bind("Id,Title,ImagePath,IsBanner,GameId")] HighlightGame highlightGame, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                highlightGame.ImagePath = "~/uploads/" + imageFolder + "/" + file.FileName.Trim();
                _upload.UploadFile(file, imageFolder);
                _context.Add(highlightGame);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GameId"] = new SelectList(_context.Games, "Id", "Id", highlightGame.GameId);
            return(View(highlightGame));
        }
예제 #3
0
        public async Task <IActionResult> Create([Bind("Id,Name,City,LogoPath,ArenaId,LeagueId")] Team team, IFormFile file)
        {
            if (ModelState.IsValid)
            {
                team.LogoPath = "~/uploads/" + teamsFolder + "/" + file.FileName.Trim();
                _upload.UploadFile(file, teamsFolder);
                _context.Add(team);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ArenaId"]  = new SelectList(_context.Arenas, "Id", "Name", team.ArenaId);
            ViewData["LeagueId"] = new SelectList(_context.Leagues, "Id", "Name", team.LeagueId);
            return(View(team));
        }