private void Save(object sender, EventArgs e) { file_info info = this.fileinfoBindingSource.DataSource as file_info; info.File_Content = txt_content.Text; fileContext.Entry <file_info>(info).State = System.Data.Entity.EntityState.Modified; fileContext.SaveChanges(); }
public ActionResult DeleteFile(int id) { Fileinfo fi = db.Fileinfos.Find(id); db.Entry(fi).State = EntityState.Deleted; db.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public async Task <FileReference> InsertFileReferenceAsync(FileReference fileReference) { if (await _context.FileReferences.AnyAsync(p => p.AuthorId == fileReference.Author.Id && p.Name == fileReference.Name)) { throw new FileReferenceAlreadyExistsException(); } _context.FileReferences.Add(fileReference); _context.Entry(fileReference.Author).State = EntityState.Unchanged; var saved = await _context.SaveChangesAsync(); return(fileReference); }