public async Task <IActionResult> UpdateVideo(int id, VideoUpdateDto videoUpdateDto) { var video = await _repos.GetVideo(id); if (video != null) { _mapper.Map(videoUpdateDto, video); } if (await _repos.SaveAll()) { return(NoContent()); } return(BadRequest("Update failed")); }
public async Task <ActionResult> Update(VideoUpdateDto videoData, int id) { if (!ModelState.IsValid) { _logger.LogError("In cvideo controller, update video model invalid"); return(BadRequest(ModelState)); } var num = await _videoRepo.UpdateVideo(videoData, id); if (num < 1) { _logger.LogError("In cvideo controller, update video received 0 from repo"); return(BadRequest("The video item was not updated.")); } var confirm = _confirm.ConfirmResponse(true, "A Video item was updated successfully."); return(Ok(confirm)); }
public async Task <int> UpdateVideo(VideoUpdateDto vUpdateObj, int id) { var video2Update = await _context.MissionVideos.FindAsync(id); if (video2Update == null) { throw new Exception("Video to be updated is not found."); } video2Update.Title = vUpdateObj.Title; video2Update.Description = vUpdateObj.Description; _context.MissionVideos.Update(video2Update); var numbr = await _context.SaveChangesAsync(); if (numbr.Equals(0)) { return(0); } return(numbr); }