public void UpdateDetails(IBaseDB baseDB, articleContent content, ICollection <articleComment> comments) { var articleContent = baseDB.Table <articleContent>().FirstOrDefault(x => x.id == content.id); if (articleContent == null) { baseDB.Set <articleContent>().Add(content); } else { baseDB.Entry <articleContent>(content).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } foreach (var item in comments) { var articleComment = baseDB.Table <articleComment>().FirstOrDefault(x => x.id == item.id); if (articleComment == null) { baseDB.Set <articleComment>().Add(articleComment); } else { baseDB.Entry <articleComment>(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } } }
public bool Create(articleInfoDto entity) { var dbEntity = _mapper.Map <articleInfo>(entity); _baseDB.Set <articleInfo>().Add(dbEntity); return(_baseDB.Commit()); }
public void RegisterModified <TEntity>(TEntity obj) where TEntity : AggregateRoot { if (context.Entry(obj).State == EntityState.Detached) { context.Set <TEntity>().Attach(obj); } context.Entry(obj).State = EntityState.Modified; IsCommitted = false; }