private NewsModel ProjectToNewsModel(Data.Entities.News model) => new NewsModel { Title = model.Title, Content = model.Content, PublishDate = model.PublishDate };
public async Task <Option <NewsServiceModel, Error> > Create(NewsModel model) { if (await ExistsByTitle(model.Title)) { return(Option.None <NewsServiceModel, Error>(new Error($"News with title '{model.Title}' already exists!"))); } var news = new Data.Entities.News { Title = model.Title, Content = model.Content, PublishDate = model.PublishDate }; await _applicationDbContext.News.AddAsync(news); await _applicationDbContext.SaveChangesAsync(); return(Map <NewsServiceModel>(news).Some <NewsServiceModel, Error>()); }
private bool CompareNewsExact(Data.Entities.News thisNews, Data.Entities.News otherNews) => thisNews.Id == otherNews.Id && thisNews.Title == otherNews.Title && thisNews.Content == otherNews.Content && thisNews.PublishDate == otherNews.PublishDate;