Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("CategoryId,CategoryName,PostId")] Category category)
        {
            if (id != category.CategoryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(category);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CategoryExists(category.CategoryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostId"] = new SelectList(_context.Posts, "PostId", "PostId", category.PostId);
            return(View(category));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("UserId,UserName,UserPassword")] Users users)
        {
            if (id != users.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(users);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersExists(users.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(users));
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> Edit(int id, [Bind("PostId,Post,UserId,CategoryId")] Posts posts)
        {
            if (id != posts.PostId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(posts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PostsExists(posts.PostId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Category, "CategoryId", "CategoryId", posts.CategoryId);
            ViewData["UserId"]     = new SelectList(_context.Users, "UserId", "UserId", posts.UserId);
            return(View(posts));
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("VolunteerId,Name,Surname,Email,VolunteerPassword,PhoneNumber")] Volunteers volunteers)
        {
            if (id != volunteers.VolunteerId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(volunteers);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!VolunteersExists(volunteers.VolunteerId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(volunteers));
        }