public void DeleteFile(int id) { var file = _contextProvider.Context.File.Where(x => x.Id == id).FirstOrDefault(); var fileContext = new FileUploadDbContext(); fileContext.File.Attach((file)); fileContext.Entry(file).State = System.Data.Entity.EntityState.Deleted; fileContext.SaveChanges(); }
public void EditFile(Protiviti.Boilerplate.Server.Api.FileUpload.Entity.File editedFile) { var file = _contextProvider.Context.File.Where(x => x.Id == editedFile.Id).FirstOrDefault(); file.FileName = editedFile.FileName; file.Title = editedFile.Title; var fileContext = new FileUploadDbContext(); fileContext.File.Attach((file)); fileContext.Entry(file).State = System.Data.Entity.EntityState.Modified; fileContext.SaveChanges(); }