internal bool DeleteFile(int fileId) { bool result = false; try { using (FileStoreModel db = new FileStoreModel()) { PersonalFile pf = db.PersonalFiles.Find(fileId); if (pf != null) { pf.IsActive = false; db.Entry(pf).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } LogManager.LogTransaction("PersonalFile", AppVariables.UserId, fileId, TransactionTypes.Delete); result = true; } catch (Exception ex) { result = false; LogManager.LogException(ex, AppVariables.UserId, "FileManager", "DeleteFile"); } return(result); }
internal bool UpdateFile(PersonalFile file) { bool result = false; try { if (file != null) { using (FileStoreModel db = new FileStoreModel()) { PersonalFile pf = null; pf = db.PersonalFiles.Find(file.Id); if (pf != null) { pf.FileName = file.FileName; pf.FileContent = file.FileContent; db.Entry(pf).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); result = true; } } } if (result) { LogManager.LogTransaction("PersonalFile", AppVariables.UserId, file.Id, TransactionTypes.Update); } } catch (Exception ex) { result = false; LogManager.LogException(ex, AppVariables.UserId, "FileManager", "UpdateFile"); } return(result); }