public void AddAuthorToSeries(Id authorId, Id seriesId, AuthorType authorType) { var rel = new SeriesAuthor { AuthorId = authorId, SeriesId = seriesId, AuthorType = authorType, }; m_DBService.InsertOrUpdate(rel); }
// GET: Series/Details/5 public ActionResult Details(int id) { using (BLLContext ctx = new BLLContext()) { SeriesBO series = ctx.GetSeries(id); AuthorBO author = ctx.GetAuthor(series.AuthorID_FK); SeriesAuthor m = new SeriesAuthor(); m.SeriesID = series.SeriesID; m.SeriesTitle = series.SeriesTitle; m.AuthorName = author.Name; return(View(m)); } }
public bool AddSeries(AddSeriesCreate model) { foreach (int seriesId in model.Series) { var entity = new SeriesAuthor() { AuthorId = model.AuthorId, SeriesId = seriesId }; using (var ctx = new ApplicationDbContext()) { ctx.SeriesAuthors.Add(entity); var changes = ctx.SaveChanges(); } } return(true); }
public bool RemoveAuthor(AddAuthorsCreate model) { foreach (int authorId in model.Authors) { var entity = new SeriesAuthor() { AuthorId = authorId, SeriesId = model.SeriesId }; using (var ctx = new ApplicationDbContext()) { ctx.SeriesAuthors.Attach(entity); ctx.SeriesAuthors.Remove(entity); var changes = ctx.SaveChanges(); } } return(true); }