/// <summary> /// Add new comment to video. /// </summary> /// <param name="video"></param> /// <param name="comment"></param> /// <returns></returns> public Task <Result> AddComment(string videoId, string userId, string comment) { var videoDb = _videoRepository.GetById(videoId); var commentDb = new CommentDb() { CommentId = Guid.NewGuid().ToString(), Date = DateTime.Now, Text = comment, VideoId = videoDb }; try { _videoRepository.AddComment(userId, commentDb); return(Task.FromResult(Result.Ok())); } catch (DbUpdateConcurrencyException e) { return(Task.FromResult(Result.Fail($"Cannot add comment to video. {e.Message}"))); } catch (DbUpdateException e) { return(Task.FromResult(Result.Fail($"Cannot add comment to video. Duplicate field. {e.Message}"))); } catch (DbEntityValidationException e) { return(Task.FromResult(Result.Fail($"Invalid tag. {e.Message}"))); } }