public static Chapter MapDomainToDB(Domain.Models.Chapter model) { return(new Chapter { Title = model.Title, Text = model.Text, EpicId = model.EpicID }); }
public static ChapterModel Map(Domain.Models.Chapter chapter) { return(new ChapterModel { ID = chapter.ID, Title = chapter.Title, Date = chapter.Date, Text = chapter.Text, EpicID = chapter.EpicID }); }
public static Chapter Map(Domain.Models.Chapter model) { return(new Chapter { Id = model.ID, DateCreated = model.Date, Text = model.Text, Title = model.Title, EpicId = model.EpicID }); }
public bool DeleteChapter(Domain.Models.Chapter chapter) { var dbChapter = _context.Chapters.FirstOrDefault(c => c.Id == chapter.ID); //not really sure what remove does when chapter doesn't exist so //return false now. if (dbChapter == null) { return(false); } _context.Chapters.Remove(dbChapter); _context.SaveChanges(); return(true); }
public bool UpdateChapter(Domain.Models.Chapter chapter) { var dbChapter = _context.Chapters.FirstOrDefault(c => c.Id == chapter.ID); if (dbChapter == null) { //chapter doesn't exist return(false); } dbChapter.Title = chapter.Title; dbChapter.Text = chapter.Text; _context.SaveChanges(); return(true); }
public bool AddChapter(Domain.Models.Chapter chapter) { var dbEpic = _context.Epics .FirstOrDefault(e => e.Id == chapter.EpicID); //Epic does not exist in database return false if (dbEpic == null) { return(false); } var dbChapter = Mappers.ChapterMapper.MapDomainToDB(chapter); _context.Chapters.Add(dbChapter); _context.SaveChanges(); return(true); }