public async Task <string> Create(VideoCreateModel data) { if (!string.IsNullOrWhiteSpace(data.Description) && !string.IsNullOrWhiteSpace(data.Url)) { await this.ReindexVideos(); //Increment each video's index with 1, so that the new video comes first Video video = new Video { Url = data.Url, Description = data.Description, Index = 1 }; await this.db.Videos.AddAsync(video); await this.db.SaveChangesAsync(); return(video.Id); } else { throw new ArgumentException(ErrorMessages.InvalidVideoCreateData); } }
public async Task <IActionResult> Create([FromBody] VideoCreateModel video) { return(await this.Execute(true, true, async() => { string id = await this.videos.Create(video); return this.Ok(new { videoId = id }); })); }