public async Task <int> EditInstrumentAsync(EditInstrumentBindingModel model) { var instrument = this.DbContext .Instruments .FirstOrDefault(x => x.Id == model.Id); if (instrument == null) { return(ErrorId); } instrument.Description = model.Description; instrument.PhotoURL = model.PhotoURL; instrument.HighLightVideoURL = model.HighLightVideoURL; instrument.AdditionalInfoURL = model.AdditionalInfoURL; if (instrument.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { instrument.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(instrument.HighLightVideoURL); } await this.DbContext.SaveChangesAsync(); return(instrument.Id); }
public async Task <int> EditReviewAsync(EditReviewBindingModel model) { var review = this.DbContext .Reviews .FirstOrDefault(x => x.Id == model.Id); if (review == null) { return(ErrorId); } review.Content = model.Content; review.PhotoURL = model.PhotoURL; review.HighLightVideoURL = model.HighLightVideoURL; review.AdditionalInfoURL = model.AdditionalInfoURL; if (review.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { review.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(review.HighLightVideoURL); } await this.DbContext.SaveChangesAsync(); return(review.Id); }
public async Task <int> EditGameAsync(EditGameBindingModel model) { var game = this.DbContext .Games .FirstOrDefault(x => x.Id == model.Id); if (game == null) { return(ErrorId); } game.Description = model.Description; game.PhotoURL = model.PhotoURL; game.HighLightVideoURL = model.HighLightVideoURL; game.AdditionalInfoURL = model.AdditionalInfoURL; if (game.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { game.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(game.HighLightVideoURL); } await this.DbContext.SaveChangesAsync(); return(game.Id); }
public async Task <int> EditSongAsync(EditSongBindingModel model) { var song = this.DbContext .Songs .FirstOrDefault(x => x.Id == model.Id); if (song == null) { return(ErrorId); } song.Description = model.Description; song.PhotoURL = model.PhotoURL; song.HighLightVideoURL = model.HighLightVideoURL; song.AdditionalInfoURL = model.AdditionalInfoURL; if (song.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { song.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(song.HighLightVideoURL); } await this.DbContext.SaveChangesAsync(); return(song.Id); }
public void ModifyVideoURLToEmbed_ShouldWorkCorrectly() { string inputUrl = TestConstants.Helpers.VideoInputURL; string resultUrl = ModifyVideoURL_Embeded.ModifyEmbed(inputUrl); Assert.AreEqual(resultUrl, TestConstants.Helpers.VideoExpectedOutputURL); }
public async Task <int> AddArticleAsync(AddArticleBindingModel model) { var checkForDuplicate = this.DbContext .Articles .FirstOrDefault(x => x.Title == model.Title); if (checkForDuplicate != null) { return(ErrorId); } model.Content = Html_String_Utility.EncodeThisPropertyForMe(model.Content); model.HighLightVideoURL = Html_String_Utility.EncodeThisPropertyForMe(model.HighLightVideoURL); model.PhotoURL = Html_String_Utility.EncodeThisPropertyForMe(model.PhotoURL); model.Title = Html_String_Utility.EncodeThisPropertyForMe(model.Title); var article = this.Mapper.Map <Article>(model); var articleCategory = this.DbContext .ArticleCategories .FirstOrDefault(x => x.CategoryName == model.ArticleCategoryName); if (articleCategory == null) { articleCategory = new ArticleCategory() { CategoryName = model.ArticleCategoryName }; await this.DbContext.ArticleCategories.AddAsync(articleCategory); await this.DbContext.SaveChangesAsync(); } article.ArticleCategoryId = articleCategory.Id; if (article.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { article.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(article.HighLightVideoURL); } await this.DbContext.Articles.AddAsync(article); await this.DbContext.SaveChangesAsync(); return(article.Id); }
public async Task <int> AddBookAuthorAsync(AddBookAuthorBindingModel model) { var checkForDuplicate = this.DbContext .BookAuthors .FirstOrDefault(x => x.FullName == model.FullName); if (checkForDuplicate != null) { return(ErrorId); } var newAuthor = this.Mapper.Map <BookAuthor>(model); var authorGenre = this.DbContext .BookAuthorGenres .FirstOrDefault(x => x.AuthorGenreName == model.BookAuthorGenreStr); if (authorGenre == null) { authorGenre = new BookAuthorGenre() { AuthorGenreName = model.BookAuthorGenreStr }; await this.DbContext.BookAuthorGenres.AddAsync(authorGenre); await this.DbContext.SaveChangesAsync(); } newAuthor.BookAuthorGenreId = authorGenre.Id; newAuthor.BookAuthorGenre = authorGenre; if (newAuthor.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { newAuthor.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(newAuthor.HighLightVideoURL); } await this.DbContext.BookAuthors.AddAsync(newAuthor); await this.DbContext.SaveChangesAsync(); return(newAuthor.Id); }
public async Task <int> AddInstrumentAsync(AddInstrumentBindingModel model) { var checkForDuplicate = this.DbContext .Instruments .FirstOrDefault(x => x.ModelName == model.ModelName); if (checkForDuplicate != null) { return(ErrorId); } var instrument = this.Mapper.Map <Instrument>(model); var instrumentType = this.DbContext .InstrumentTypes .FirstOrDefault(x => x.Id == model.InstrumentTypeId); var brand = this.DbContext .Brands .FirstOrDefault(x => x.Id == model.BrandId); instrument.InstrumentTypeId = instrumentType.Id; instrument.InstrumentType = instrumentType; instrument.BrandId = brand.Id; instrument.Brand = brand; if (instrument.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { instrument.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(instrument.HighLightVideoURL); } await this.DbContext.Instruments.AddAsync(instrument); await this.DbContext.SaveChangesAsync(); return(instrument.Id); }
public async Task <int> AddGameAsync(AddGameBindingModel model) { var checkForDuplicate = this.DbContext .Games .FirstOrDefault(x => x.GameName == model.GameName); if (checkForDuplicate != null) { return(ErrorId); } var game = this.Mapper.Map <Game>(model); var gameType = this.DbContext .GameTypes .FirstOrDefault(x => x.Id == model.GameTypeId); var brand = this.DbContext .Brands .FirstOrDefault(x => x.Id == model.BrandId); game.GameTypeId = gameType.Id; game.GameType = gameType; game.BrandId = brand.Id; game.Brand = brand; if (game.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { game.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(game.HighLightVideoURL); } await this.DbContext.Games.AddAsync(game); await this.DbContext.SaveChangesAsync(); return(game.Id); }
public async Task <int> AddReviewAsync(AddReviewBindingModel model) { var checkForDuplicate = this.DbContext .Reviews .FirstOrDefault(x => x.Title == model.Title); if (checkForDuplicate != null) { return(ErrorId); } var review = this.Mapper.Map <Review>(model); if (review.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { review.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(review.HighLightVideoURL); } await this.DbContext.Reviews.AddAsync(review); await this.DbContext.SaveChangesAsync(); return(review.Id); }
public async Task <int> AddArtistAsync(AddArtistBindingModel model) { var checkForDuplicate = this.DbContext .Artists .FirstOrDefault(x => x.FullName == model.FullName); if (checkForDuplicate != null) { return(ErrorId); } var artist = this.Mapper.Map <Artist>(model); if (artist.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { artist.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(artist.HighLightVideoURL); } await this.DbContext.Artists.AddAsync(artist); await this.DbContext.SaveChangesAsync(); return(artist.Id); }
public async Task <int> AddSongAsync(AddSongBindingModel model) { var checkForDuplicate = this.DbContext .Songs .FirstOrDefault(x => x.SongName == model.SongName); if (checkForDuplicate != null) { return(ErrorId); } var song = this.Mapper.Map <Song>(model); if (song.HighLightVideoURL.Contains(CommonConstants.OriginalVideoUrlPart)) { song.HighLightVideoURL = ModifyVideoURL_Embeded.ModifyEmbed(song.HighLightVideoURL); } await this.DbContext.Songs.AddAsync(song); await this.DbContext.SaveChangesAsync(); return(song.Id); }