Beispiel #1
0
        public async Task <IActionResult> Create([Bind("Id,GameTitle,PlatformsId,CategoryId,RatingId,Synopsis,CompanyId")] Games games,
                                                 IFormFile FilePhoto)
        {
            if (FilePhoto.Length > 0)
            {
                string coverLogo = _webroot.WebRootPath + "\\gamePhotos\\";
                var    fileName  = Path.GetFileName(FilePhoto.FileName);

                using (var stream = System.IO.File.Create(coverLogo + fileName))
                {
                    await FilePhoto.CopyToAsync(stream);

                    games.CoverLogo = fileName;
                }
            }
            if (ModelState.IsValid)
            {
                _context.Add(games);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"]  = new SelectList(_context.Categories, "Id", "Category", games.CategoryId);
            ViewData["CompanyId"]   = new SelectList(_context.Company, "Id", "CompanyName", games.CompanyId);
            ViewData["PlatformsId"] = new SelectList(_context.Platforms, "Id", "PlatformName", games.PlatformsId);
            ViewData["RatingId"]    = new SelectList(_context.Rating, "Id", "RatingNum", games.RatingId);
            return(View(games));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,DisplayName,DateCreated,UserTypeId,UserAccountId")] UserProfiles userProfiles)
        {
            if (ModelState.IsValid)
            {
                _context.Add(userProfiles);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ProfileInfo)));
            }
            ViewData["UserTypeId"] = new SelectList(_context.UserType, "Id", "TypeName", userProfiles.UserTypeId);
            return(View(userProfiles));
        }
Beispiel #3
0
        public async Task <IActionResult> Create([Bind("Comment,DatePosted,UserProfilesId,GuideId")] Comments comments)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comments);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(ViewComments)));
            }
            //ViewData["UserProfilesId"] = new SelectList(_context.UserProfiles, "Id", "DisplayName", comments.UserProfilesId);
            return(View(comments));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("GuideTitle,GuideContent,DateSubmitted,LastUpdated,UserProfilesId,GameId")] Guides guides)
        {
            if (ModelState.IsValid)
            {
                _context.Add(guides);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Guide)));
            }
            ViewData["GameId"] = new SelectList(_context.Games, "Id", "GameTitle", guides.GameId);
            //ViewData["UserProfilesId"] = new SelectList(_context.UserProfiles, "Id", "DisplayName", guides.UserProfilesId);
            return(View(guides));
        }