public async Task <IActionResult> Create(Post post)
        {
            if (ModelState.IsValid)
            {
                foreach (BlogPostRec rec in post.BlogPostRecs.Where(x => x.isChecked == false))
                {
                    post.BlogPostRecs.Remove(rec);
                }
                _context.Add(post);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            post.BlogPostRecs = new List <BlogPostRec>();
            foreach (Blog b in _context.Blogs)
            {
                BlogPostRec bpr = new BlogPostRec()
                {
                    BlogId = b.Id, Blog = b
                };
                post.BlogPostRecs.Add(bpr);
            }
            post.CreatedDate = DateTime.Now;
            post.BlogPostRecs.OrderBy(x => x.Blog.BlogName);
            return(View(post));
        }
        public async Task <IActionResult> Create([Bind("Id,Category1")] Category category)
        {
            if (ModelState.IsValid)
            {
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Create([Bind("Id,OrganizationName,OrganizationDescription,CreatedDate,Active")] Organization organization)
        {
            if (ModelState.IsValid)
            {
                _context.Add(organization);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(organization));
        }
Exemple #4
0
        public async Task <IActionResult> Create([Bind("Id,GenderName")] Gender gender)
        {
            if (ModelState.IsValid)
            {
                _context.Add(gender);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(gender));
        }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("Id,TermName,TermDescription,CreatedDate,TermStartDate,TermEndDate,Active")] Term term)
        {
            if (ModelState.IsValid)
            {
                _context.Add(term);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(term));
        }
        public async Task <IActionResult> Create([Bind("Id,BlogName,CreatedDate,LastPostDate,BlogHeader,BlogSubHeader,BlogDescription,Active")] Blog blog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(blog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
        public async Task <IActionResult> Create([Bind("Id,OrganizationId,GroupName,GroupDescription,CreatedDate,Active")] Group @group)
        {
            if (ModelState.IsValid)
            {
                _context.Add(@group);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "OrganizationName", @group.OrganizationId);
            return(View(@group));
        }
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,CreatedDate,GenderId")] Player player)
        {
            if (ModelState.IsValid)
            {
                _context.Add(player);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "GenderName", player.GenderId);
            return(View(player));
        }
        public async Task <IActionResult> Create([Bind("Id,PlayerId,SessionId,Attended,WorkEthic,TechnicalImprovementDuringSession,TechnicalImprovementFromPreviousSession,Notes")] PlayerForSession playerForSession)
        {
            if (ModelState.IsValid)
            {
                _context.Add(playerForSession);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PlayerId"]  = new SelectList(_context.Players, "Id", "FirstName", playerForSession.PlayerId);
            ViewData["SessionId"] = new SelectList(_context.Sessions, "Id", "Id", playerForSession.SessionId);
            return(View(playerForSession));
        }
        public async Task <IActionResult> Create(Session session)
        {
            if (ModelState.IsValid)
            {
                foreach (PlayerForSession rec in session.PlayerForSessions)
                {
                    if (rec.isChecked == false)
                    {
                        session.PlayerForSessions.Remove(rec);
                    }
                    else
                    {
                        rec.Attended = true;
                    }
                    if (rec.Notes == null)
                    {
                        rec.Notes = "";
                    }
                }
                _context.Add(session);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            Session s = new Session()
            {
                IsActive = true, IsDraft = true, SessionDate = DateTime.Now, PlayerForSessions = new List <PlayerForSession>()
            };

            foreach (Player p in _context.Players.OrderBy(x => x.LastName))
            {
                PlayerForSession ps = new PlayerForSession()
                {
                    Player = p, PlayerId = p.Id
                };
                s.PlayerForSessions.Add(ps);
            }
            ViewData["GroupId"] = new SelectList(_context.Groups, "Id", "GroupName", session.GroupId);
            ViewData["PostId"]  = new SelectList(_context.Posts, "Id", "PostHeader", session.PostId);
            ViewData["TermId"]  = new SelectList(_context.Terms, "Id", "TermName", session.TermId);
            return(View(session));
        }