Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ApplicationResponseID,Category,Title,Year,Director,Rating,Edited,Lent_To,Notes")] ApplicationResponse applicationResponse)
        {
            if (id != applicationResponse.ApplicationResponseID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(applicationResponse);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ApplicationResponseExists(applicationResponse.ApplicationResponseID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(applicationResponse));
        }
Example #2
0
 public async Task <IActionResult> AddOrEdit(int id, [Bind("MovieID,TmdbID,Title,Year,Type,Genre,Poster,Trailer,Quality")] MovieListModel movieListModel)
 {
     if (ModelState.IsValid)
     {
         //Insert
         if (id == 0)
         {
             _context.Add(movieListModel);
             await _context.SaveChangesAsync();
         }
         //Update
         else
         {
             try
             {
                 _context.Update(movieListModel);
                 await _context.SaveChangesAsync();
             }
             catch (DbUpdateConcurrencyException)
             {
                 if (!MovieListModelExists(movieListModel.MovieID))
                 {
                     return(NotFound());
                 }
                 else
                 {
                     throw;
                 }
             }
         }
         return(Json(new { isValid = true, html = Helper.RenderRazorViewToString(this, "_ViewAll", _context.MovieLists.ToList()) }));
     }
     return(Json(new { isValid = false, html = Helper.RenderRazorViewToString(this, "AddOrEdit", movieListModel) }));
 }