/// <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> /// 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> /// Deletes genre from db /// </summary> /// <param name="item">Genre id</param> /// <returns>System.Boolean</returns> public bool Delete(Model.Genres.Genre item) { try { using (var context = new AngularJsSampleDbEntities()) { context.Genre_Delete(item.Id, item.UserLastModified?.Id); return(true); } } catch (Exception e) { Console.WriteLine($"The exception is: '{e}'"); return(false); } }
/// <summary> /// Maps Model.Genre.Genre into Messaging.Views.Genre.Genre /// </summary> /// <param name="model">Model.Genre.Genre</param> /// <returns>Messaging.Views.Genre.Genre</returns> public static Messaging.Views.Genres.Genre MapToView(this Model.Genres.Genre model) { return(Mapper.Map <Messaging.Views.Genres.Genre>(model)); }