public async Task PutAsync(int id, VideoTaskDto model) { var videoTask = await _context.VideoTasks.FindAsync(id); videoTask.Name = model.Name; videoTask.Description = model.Description; videoTask.VideoHref = model.VideoHref; videoTask.Module = await _context.Modules.FindAsync(model.ModuleId); _context.Entry(videoTask).State = EntityState.Modified; await _context.SaveChangesAsync(); }
public async Task <VideoTask> CreateAsync(VideoTaskDto model) { var videoTask = new VideoTask { Name = model.Name, Description = model.Description, VideoHref = model.VideoHref, Module = await _context.Modules.FindAsync(model.ModuleId) }; _context.VideoTasks.Add(videoTask); await _context.SaveChangesAsync(); return(videoTask); }
public async Task <IActionResult> PutVideoTask(int id, VideoTaskDto videoTask) { try { await _videoTasksService.PutAsync(id, videoTask); } catch (DbUpdateConcurrencyException) { if (!_videoTasksService.VideoTaskExists(id)) { return(NotFound()); } throw; } return(NoContent()); }
public async Task <ActionResult <UlearnData.Models.Tasks.VideoTasks.VideoTask> > PostVideoTask(VideoTaskDto videoTask) { var newVideoTask = await _videoTasksService.CreateAsync(videoTask); return(CreatedAtAction("GetVideoTask", new { id = newVideoTask.Id }, newVideoTask)); }