Пример #1
0
        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();
        }
Пример #2
0
        public ActionResult DeleteFile(int id)
        {
            Fileinfo fi = db.Fileinfos.Find(id);

            db.Entry(fi).State = EntityState.Deleted;
            db.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
Пример #3
0
        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);
        }