public async Task <IActionResult> Edit(int id, [Bind("Id,Name,UserId,ContentTypeId")] Content content)
        {
            if (id != content.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(content);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContentExists(content.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContentTypeId"] = new SelectList(_context.ContentTypes, "Id", "Id", content.ContentTypeId);
            ViewData["UserId"]        = new SelectList(_context.Users, "Id", "Login", content.UserId);
            return(View(content));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] ContentType contentType)
        {
            if (id != contentType.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contentType);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContentTypeExists(contentType.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(contentType));
        }
Example #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ContentId,UserId,Rating")] UsersRating usersRating)
        {
            if (id != usersRating.UserId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(usersRating);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsersRatingExists(usersRating.UserId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContentId"] = new SelectList(_context.Contents, "Id", "Discriminator", usersRating.ContentId);
            ViewData["UserId"]    = new SelectList(_context.Users, "Id", "Login", usersRating.UserId);
            return(View(usersRating));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Login,City")] User user)
        {
            if (id != user.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    context.Update(user);
                    await context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UserExists(user.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
 internal void Vote(int id, string operation)
 {
     if (operation.Equals("plus"))
     {
         GetId(id).Votes++;
     }
     else if (operation.Equals("minus"))
     {
         GetId(id).Votes--;
     }
     contentContext.Update(GetId(id));
     contentContext.SaveChanges();
 }