public async Task<IHttpActionResult> AddVideo(VideoModel model) { try { var video = new DrNajeeb.EF.Video(); video.Name = model.Name; video.Description = model.Description; video.Duration = model.Duration; video.ReleaseYear = model.ReleaseYear; if (video.DateLive != null) { video.DateLive = model.DateLive.Value; } else { video.DateLive = DateTime.UtcNow; } video.BackgroundColor = model.BackgroundColor; video.IsEnabled = model.IsEnabled; video.StandardVideoId = model.StandardVideoId; video.FastVideoId = model.FastVideoId; video.Active = true; video.CreatedOn = DateTime.UtcNow; //todo : add useid in createdby _Uow._Videos.Add(video); await _Uow.CommitAsync(); return Ok(); } catch (Exception ex) { return InternalServerError(ex); } }
public async Task<IHttpActionResult> GetSingle(int Id) { try { var video = await _Uow._Videos.GetByIdAsync(Id); if (video == null) { return NotFound(); } var model = new VideoModel(); model.Name = video.Name; model.Description = video.Description; model.Duration = video.Duration; model.ReleaseYear = video.ReleaseYear; if (model.DateLive != null) { model.DateLive = video.DateLive; } model.BackgroundColor = video.BackgroundColor; model.IsEnabled = video.IsEnabled; model.StandardVideoId = video.StandardVideoId; model.FastVideoId = video.StandardVideoId; return Ok(model); } catch (Exception ex) { return InternalServerError(ex); } }
public async Task<IHttpActionResult> UpdateSubscription(VideoModel model) { try { var video = await _Uow._Videos.GetByIdAsync(model.Id); video.Name = model.Name; video.Description = model.Description; video.Duration = model.Duration; video.ReleaseYear = model.ReleaseYear; if (video.DateLive != null) { video.DateLive = model.DateLive.Value; } video.BackgroundColor = model.BackgroundColor; video.IsEnabled = model.IsEnabled; video.StandardVideoId = model.StandardVideoId; video.FastVideoId = model.StandardVideoId; //todo : add useid in updatedby _Uow._Videos.Update(video); await _Uow.CommitAsync(); return Ok(); } catch (Exception ex) { return InternalServerError(ex); } }