public async Task <IActionResult> Edit(int id, [Bind("Id,Category1")] Category category)
        {
            if (id != category.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,CreatedDate,GenderId")] Player player)
        {
            if (id != player.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(player);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerExists(player.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["GenderId"] = new SelectList(_context.Genders, "Id", "GenderName", player.GenderId);
            return(View(player));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,OrganizationName,OrganizationDescription,CreatedDate,Active")] Organization organization)
        {
            if (id != organization.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(organization);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrganizationExists(organization.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(organization));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,OrganizationId,GroupName,GroupDescription,CreatedDate,Active")] Group @group)
        {
            if (id != @group.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@group);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GroupExists(@group.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OrganizationId"] = new SelectList(_context.Organizations, "Id", "OrganizationName", @group.OrganizationId);
            return(View(@group));
        }
Exemple #5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,GenderName")] Gender gender)
        {
            if (id != gender.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(gender);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!GenderExists(gender.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(gender));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,PlayerId,SessionId,Attended,WorkEthic,TechnicalImprovementDuringSession,TechnicalImprovementFromPreviousSession,Notes")] PlayerForSession playerForSession)
        {
            if (id != playerForSession.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(playerForSession);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlayerForSessionExists(playerForSession.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                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));
        }
Exemple #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,TermName,TermDescription,CreatedDate,TermStartDate,TermEndDate,Active")] Term term)
        {
            if (id != term.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(term);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TermExists(term.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(term));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,BlogName,CreatedDate,LastPostDate,BlogHeader,BlogSubHeader,BlogDescription,Active")] Blog blog)
        {
            if (id != blog.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(blog);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BlogExists(blog.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(blog));
        }
        public async Task <IActionResult> Edit(int id, Session session)
        {
            if (id != session.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (PlayerForSession ps in session.PlayerForSessions)
                    {
                        ps.SessionId = session.Id;
                        if (_context.PlayerForSessions.Any(x => x.SessionId == ps.SessionId && x.PlayerId == ps.PlayerId) && ps.isChecked == false)
                        {
                            session.PlayerForSessions.Remove(ps);
                            _context.RemoveRange(_context.PlayerForSessions.Where(x => x.SessionId == ps.SessionId && x.PlayerId == ps.PlayerId));
                        }
                        if (_context.PlayerForSessions.Any(x => x.SessionId == ps.SessionId && x.PlayerId == ps.PlayerId) && ps.isChecked == true)
                        {
                            session.PlayerForSessions.Remove(ps);
                        }
                        if (ps.isChecked == false)
                        {
                            session.PlayerForSessions.Remove(ps);
                        }
                        if (ps.isChecked == true)
                        {
                            ps.Attended = true;
                            if (ps.Notes == null)
                            {
                                ps.Notes = "";
                            }
                        }
                    }
                    _context.Update(session);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SessionExists(session.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            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);
            foreach (Player p in _context.Players)
            {
                if (session.PlayerForSessions.Any(x => x.PlayerId == p.Id))
                {
                    session.PlayerForSessions.Where(x => x.PlayerId == p.Id).First().isChecked = true;
                }
                else
                {
                    PlayerForSession ps = new PlayerForSession()
                    {
                        PlayerId = p.Id, Player = p
                    };
                    session.PlayerForSessions.Add(ps);
                }
            }
            session.PlayerForSessions.OrderBy(x => x.Player.LastName);
            return(View(session));
        }
        public async Task <IActionResult> Edit(int id, Post post)
        {
            if (id != post.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    foreach (BlogPostRec pr in post.BlogPostRecs)
                    {
                        pr.PostId = post.Id;
                        if (_context.BlogPostRecs.Any(x => x.PostId == pr.PostId && x.BlogId == pr.BlogId) && pr.isChecked == false)
                        {
                            post.BlogPostRecs.Remove(pr);
                            _context.RemoveRange(_context.BlogPostRecs.Where(x => x.PostId == pr.PostId && x.BlogId == pr.BlogId));
                        }
                        if (_context.BlogPostRecs.Any(x => x.PostId == pr.PostId && x.BlogId == pr.BlogId) && pr.isChecked == true)
                        {
                            post.BlogPostRecs.Remove(pr);
                        }
                        if (pr.isChecked == false)
                        {
                            post.BlogPostRecs.Remove(pr);
                        }
                    }
                    _context.Update(post);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostExists(post.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            foreach (Blog b in _context.Blogs)
            {
                if (post.BlogPostRecs.Any(x => x.BlogId == b.Id))
                {
                    post.BlogPostRecs.Where(x => x.BlogId == b.Id).First().isChecked = true;
                }
                else
                {
                    BlogPostRec bpr = new BlogPostRec()
                    {
                        BlogId = b.Id, Blog = b
                    };
                    post.BlogPostRecs.Add(bpr);
                }
            }
            post.BlogPostRecs.OrderBy(x => x.Blog.BlogName);
            return(View(post));
        }