public TranslatedVideo Patch(string id, Video patch) { var video = _db.Videos.Include(c => c.Translations).SingleOrDefault(c => c.Id == id); video.Patch(patch); return new TranslatedVideo(video); }
public void Patch(Video patch) { if (patch.YouTubeVideoId != null) YouTubeVideoId = patch.YouTubeVideoId; if (patch.VotesUp != null) VotesUp = patch.VotesUp; if (patch.VotesDown != null) VotesDown = patch.VotesDown; foreach (var translationPatch in patch.Translations) { var translation = Translations.FirstOrDefault(t => t.Culture == translationPatch.Culture); if (translation == null) { continue; } if (translationPatch.Title != null) translation.Title = translationPatch.Title; if (translationPatch.Description != null) translation.Description = translationPatch.Description; } }
public TranslatedVideo(Video video) { Id = video.Id; YouTubeVideoId = video.YouTubeVideoId; VotesUp = video.VotesUp; VotesDown = video.VotesDown; if (video.Translations != null && video.Translations.Any()) { var translation = video.Translations.First(); Culture = translation.Culture; Title = translation.Title; Description = translation.Description; } }
public Video Post(Video video) { return _repository.Post(video); }
public TranslatedVideo Put(string id, Video updateVideo) { return _repository.Put(id, updateVideo); }
public TranslatedVideo Patch(string id, Video patch) { return _repository.Patch(id, patch); }
public Video Post(Video video) { _db.Videos.Add(video); return video; }
public TranslatedVideo Put(string id, Video updateVideo) { _db.Entry(updateVideo).State = EntityState.Modified; _db.Entry(updateVideo.Translations.First()).State = EntityState.Modified; return new TranslatedVideo(updateVideo); }