public void AddNote(Note note, string userId) { this.validationProvider.Validate(note); Video video = this.videoRepository.Table.Where( x => (x.VideoId == note.VideoId) && (x.Category.ApplicationUserId == userId)).FirstOrDefault(); if (video != null) { this.noteRepository.Insert(note); return; } throw new ValidationException( new List <ValidationResult>() { new ValidationResult( "user", ValidationExceptionMessages.UserNotAuthenticated( userId, "add note", note.VideoId.ToString())) }); }
public void AddVideo(Video video, string userId) { this.validationProvider.Validate(video); Category category = this.categoryRepository.GetById(video.CategoryId); if (category != null && category.ApplicationUserId == userId) { this.videoRepository.Insert(video); return; } else { throw new ValidationException(new List <ValidationResult>() { new ValidationResult("user", ValidationExceptionMessages.UserNotAuthenticated(userId, "add video", "0")) }); } }
public void DeleteCategoryById(string categoryId, string userId) { int k = int.Parse(categoryId); Category category = this.categoryRepository.GetById(k); if (category != null && category.ApplicationUserId == userId) { this.categoryRepository.Delete(category); return; } else { throw new ValidationException(new List <ValidationResult>() { new ValidationResult("user", ValidationExceptionMessages.UserNotAuthenticated(userId, "delete category", categoryId)) }); } }
public IQueryable <Note> GetNotesFor(int videoId, string userId) { Video video = this.videoRepository.GetById(videoId); if (video != null) { Category category = this.categoryRepository.GetById(video.CategoryId); if (category.ApplicationUserId == userId) { return(this.noteRepository.Table.Where(x => x.VideoId == videoId)); } } throw new ValidationException(new List <ValidationResult>() { new ValidationResult("user", ValidationExceptionMessages.UserNotAuthenticated(userId, "get notes", videoId.ToString())) }); }
public Video DeleteVideoById(string videoId, string userId) { int k = int.Parse(videoId); Video video = this.videoRepository.GetById(k); if (video != null) { Category category = this.categoryRepository.GetById(video.CategoryId); if (category.ApplicationUserId == userId) { this.videoRepository.Delete(video); return(video); } } throw new ValidationException(new List <ValidationResult>() { new ValidationResult("user", ValidationExceptionMessages.UserNotAuthenticated(userId, "delete video", videoId)) }); }
public Note DeleteNoteById(string noteId, string userId) { int k = int.Parse(noteId); Note note = this.noteRepository.GetById(k); if (note != null) { Video video = this.videoRepository.GetById(note.VideoId); Category category = this.categoryRepository.GetById(video.CategoryId); if (category.ApplicationUserId == userId) { this.noteRepository.Delete(note); return(note); } } throw new ValidationException(new List <ValidationResult>() { new ValidationResult("user", ValidationExceptionMessages.UserNotAuthenticated(userId, "delete note", noteId)) }); }