/// <summary> /// Returns list of all genres by id /// </summary> /// <param name="key">id</param> /// <returns>context.GenreData_Get</returns> public Model.Genres.Genre FindAll(int key) { using (var context = new AngularJsSampleDbEntities()) { return(context.GenreData_Get(key).SingleOrDefault().MapToModel()); } }
/// <summary> /// Adds object into db /// </summary> /// <param name="item">Model.Genres.Genre</param> /// <returns>context.Genre_Insert</returns> public int Add(Model.Genres.Genre item) { using (var context = new AngularJsSampleDbEntities()) { return(context.Genre_Insert(item.Name, item.Description, item.UserCreated?.Id)); } }
/// <summary> /// Finds movies by param key /// </summary> /// <param name="key"></param> /// <returns>Context.MovieData_Get</returns> public Model.Movies.Movie FindAll(int key) { using (var context = new AngularJsSampleDbEntities()) { return(context.MovieData_Get(key).FirstOrDefault().MapToModel()); } }
/// <summary> /// Adds items for insertion into db /// </summary> /// <returns> /// context.Movie_Insert /// </returns> /// <param name="item">Model.Movies.Movie</param> public int Add(Model.Movies.Movie item) { using (var context = new AngularJsSampleDbEntities()) { return(context.Movie_Insert(item.Name, item.ReleaseDate, item.Description, item.UserCreated.Id, item.PosterUrl, item.IMDBUrl, item.Rating)); } }
/// <summary> /// Adds object with items to POST request /// </summary> /// <param name="item">Model.MovieRatings.MovieRating object</param> /// <returns>context.Rating_Insert</returns> public int Add(Model.MovieRatings.MovieRating item) { using (var context = new AngularJsSampleDbEntities()) { return(context.Rating_Insert(item.MovieId, item.UserRatedId, item.UserCreated?.Id, item.Rating)); } }
/// <summary> /// Adds object for POST request /// </summary> /// <param name="item">Model.MoviePersons.MoviePerson</param> /// <returns>context.MoviePerson_Insert</returns> public int Add(Model.MoviePersons.MoviePerson item) { using (var context = new AngularJsSampleDbEntities()) { return(context.MoviePerson_Insert(item.FirstName, item.LastName, item.Birthday, item.BirthPlace, item.Biography, item.UserCreated?.Id, item.PhotoUrl, item.IMDBUrl, item.Popularity)); } }
/// <summary> /// Adds object to UPDATE request /// </summary> /// <param name="item"></param> /// <returns>Model.MovieRatings.MovieRating</returns> public Model.MovieRatings.MovieRating Save(Model.MovieRatings.MovieRating item) { using (var context = new AngularJsSampleDbEntities()) { context.Rating_Save(item.MovieId, item.UserRatedId, item.Rating); return(item); } }
/// <summary> /// Saves genre into db /// </summary> /// <param name="item">Model.Genres.Genre</param> /// <returns>Model.Genres.Genre</returns> public Model.Genres.Genre Save(Model.Genres.Genre item) { using (var context = new AngularJsSampleDbEntities()) { context.Genre_Save(item.Id, item.Name, item.Description, item.UserLastModified?.Id); return(item); } }
/// <summary> /// Adds items for updating existing item /// </summary> /// <returns> /// context.Movie_Save /// </returns> /// <param name="item">Model.Movies.Movie</param> public Model.Movies.Movie Save(Model.Movies.Movie item) { using (var context = new AngularJsSampleDbEntities()) { context.Movie_Save(item.Id, item.Name, item.ReleaseDate, item.Description, item.PosterUrl, item.IMDBUrl, item.Rating, item.UserLastModified?.Id); return(item); } }
/// <summary> /// Adds id for UPDATE request /// </summary> /// <param name="item">Model.MoviePersons.MoviePerson</param> /// <returns>Model.MoviePersons.MoviePerson</returns> public Model.MoviePersons.MoviePerson Save(Model.MoviePersons.MoviePerson item) { using (var context = new AngularJsSampleDbEntities()) { context.MoviePerson_Save(item.Id, item.FirstName, item.LastName, item.BirthPlace, item.Birthday, item.Biography, item.PhotoUrl, item.IMDBUrl, item.Popularity, item.UserLastModified?.Id); return(item); } }
/// <summary> /// Adds object for GET request /// </summary> /// <returns>List<Model.MoviePersons.MoviePerson></returns> public List <Model.MoviePersons.MoviePerson> FindAll() { using (var context = new AngularJsSampleDbEntities()) { List <Model.MoviePersons.MoviePerson> list = new List <Model.MoviePersons.MoviePerson>(); foreach (var item in context.MoviePerson_Get().ToList()) { list.Add(item.MapToModels()); } return(list); } }
/// <summary> /// Returns list of all genres /// </summary> /// <returns>List<Model.Genres.Genre></returns> public List <Model.Genres.Genre> FindAll() { using (var context = new AngularJsSampleDbEntities()) { List <Model.Genres.Genre> list = new List <Model.Genres.Genre>(); foreach (var item in context.Genres_Get().ToList()) { list.Add(item.MapToModels()); } return(list); } }
/// <summary> /// Adds object for DELETE request /// </summary> /// <param name="item">Model.MoviePersons.MoviePerson</param> /// <returns>System.Boolean</returns> public bool Delete(Model.MoviePersons.MoviePerson item) { try { using (var context = new AngularJsSampleDbEntities()) { context.MoviePerson_Delete(item.Id, item.UserLastModified?.Id); return(true); } } catch (Exception e) { Console.WriteLine($"The exception is: '{e}'"); return(false); } }
/// <summary> /// Adds id for GET request /// </summary> /// <param name="key">MoviePerson id</param> /// <returns>Model.MoviePersons.MoviePerson</returns> public Model.MoviePersons.MoviePerson FindAll(int key) { using (var context = new AngularJsSampleDbEntities()) { return(context.MoviePersonData_Get(key).SingleOrDefault().MapToModel()); } }