public async Task PublishDraftVersion(string contentType, string contentId, string versionCode) { var toPublish = await GetVersionInfo(contentType, contentId, versionCode); if (toPublish.Status != ContentStatus.Draft) { throw new InvalidOperationException("Only draft versions can be published"); } var oldPublished = await GetPublishedVersionInfo(contentType, contentId); if (oldPublished != null) { oldPublished.Status = ContentStatus.Archived; _connectDb.Attach <ContentVersion>(oldPublished); _connectDb.Entry(oldPublished).State = Microsoft.EntityFrameworkCore.EntityState.Modified; } toPublish.Status = ContentStatus.Published; _connectDb.Attach <ContentVersion>(toPublish); _connectDb.Entry(toPublish).State = Microsoft.EntityFrameworkCore.EntityState.Modified; await _connectDb.SaveChangesAsync(); }
public async Task <Province> Update(int id, Province province) { _context.Entry(province).State = EntityState.Modified; await _context.SaveChangesAsync(); return(province); }
public static async Task <T> updateModel(ConnectDbContext _context, T model) { _context.Entry(model).State = EntityState.Modified; await _context.SaveChangesAsync(); return(model); }
public async Task AddDocumentAsync(TDocument document, IFolder folder) { Ensure.NotNull(document, $"{nameof(document)} cannot be null."); Ensure.NotNull(folder, $"{nameof(folder)} cannot be null."); var item = await GetItemAsync(document.DocumentId, folder.Id); if (item == null) { using (var db = new ConnectDbContext(_db)) { item = new FolderItem() { AllowComments = true, DocumentId = document.DocumentId, Folder = folder as Folder, FolderId = folder.Id, Id = KeyGen.NewGuid(), InheritSecurity = false, InheritSharing = false, InheritTags = false, ItemStatus = ModerationStatus.Approved }; // No async, since we are in a lock db.Entry(item).State = EntityState.Added; await db.FolderItems.AddAsync(item); db.SaveChanges(); } } }
public async Task <FileDocument> UpdateAsync(FileDocument document) { using (var db = new ConnectDbContext(_writeDb)) { db.Attach(document); db.Entry(document).State = EntityState.Modified; db.SaveChanges(); } return(document); }
//actualizar public async Task <Pais> Update(int id, Pais pais) { if (id != pais.Id) { return(null); } _context.Entry(pais).State = EntityState.Modified; await _context.SaveChangesAsync(); return(pais); }
public void UpdateModel(TModel model) { var widget = new JsonWidget { Id = model.Id, ModelType = model.GetType().FullName, ModelJson = JsonConvert.SerializeObject(model) }; _db.Attach <JsonWidget>(widget); _db.Entry(widget).State = Microsoft.EntityFrameworkCore.EntityState.Modified; _db.SaveChanges(); }