public async Task <IActionResult> PutClassRatings(Guid id, ClassRatings classRatings) { if (id != classRatings.Id) { return(BadRequest()); } _context.Entry(classRatings).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassRatingsExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(Guid id, [Bind("Id,UserId,ClassVideoId,Rating")] ClassRatings classRatings) { if (id != classRatings.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(classRatings); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClassRatingsExists(classRatings.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ClassVideoId"] = new SelectList(_context.ClassVideo, "Id", "Id", classRatings.ClassVideoId); ViewData["UserId"] = new SelectList(_context.Profile, "UserId", "UserId", classRatings.UserId); return(View(classRatings)); }
public async Task <IActionResult> Create([Bind("Id,UserId,ClassVideoId,Rating")] ClassRatings classRatings) { if (ModelState.IsValid) { classRatings.Id = Guid.NewGuid(); _context.Add(classRatings); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["ClassVideoId"] = new SelectList(_context.ClassVideo, "Id", "Id", classRatings.ClassVideoId); ViewData["UserId"] = new SelectList(_context.Profile, "UserId", "UserId", classRatings.UserId); return(View(classRatings)); }
public async Task <ActionResult <ClassRatings> > PostClassRatings(ClassRatings classRatings) { _context.ClassRatings.Add(classRatings); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ClassRatingsExists(classRatings.Id)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetClassRatings", new { id = classRatings.Id }, classRatings)); }