public int CreateDocument(DocumentModel document) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Document dbDocument = new Document { CheckerName = "", Description = document.Description, FileDiskName = document.FileDiskName, FileDisplayName = document.FileDisplayName, Size = document.Size, PubTime = document.PubTime, PublisherName = document.PublisherName, PublisherNumber = document.PublisherNumber, FileTypeId = document.FileTypeId, FolderId = document.FolderId, AuthLevel = document.AuthLevel }; try { context.AddToDocuments(dbDocument); context.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave); } catch(Exception e){ System.Diagnostics.Debug.WriteLine(e.InnerException.Message); } return dbDocument.Id; } }
public Boolean DeleteUserAccount(UserEmployeeModel userEmployeeModel, UserEmployeeDetailModel userEmployeeDetailModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); UserEmployeeDetail dbDetail = (from detail in context.UserEmployeeDetails where detail.EmployeeNumber == userEmployeeDetailModel.EmployeeNumber select detail).FirstOrDefault(); context.DeleteObject(dbDetail); context.SaveChanges(); UserEmployee dbUser = (from user in context.UserEmployees where user.EmployeeNumber == userEmployeeModel.EmployeeNumber select user).FirstOrDefault(); context.DeleteObject(dbUser); context.SaveChanges(); return true; }
public Boolean deleteNewsById(int id) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.SiteNews dbNews = (from news in context.SiteNews where news.Id.Equals(id) select news).FirstOrDefault(); context.DeleteObject(dbNews); context.SaveChanges(); return true; }
public void DeleteFolder(FolderModel folder) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Folder dbFolder = ConvertModelToDB(folder); context.Folders.Attach(dbFolder); context.Folders.DeleteObject(dbFolder); context.SaveChanges(); } }
public Boolean deleteFavById(int employeeNumber, int documentId) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.Favorite dbFav = (from fav in context.Favorites where fav.DocumentId.Equals(documentId) && fav.EmployeeNumber.Equals(employeeNumber) select fav).FirstOrDefault(); context.DeleteObject(dbFav); context.SaveChanges(); return true; }
public Boolean addFav(int employeeNumber, int documentId) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.Favorite fav = new DAL.Favorite(); fav.EmployeeNumber = employeeNumber; fav.DocumentId = documentId; context.AddToFavorites(fav); context.SaveChanges(); return true; }
//DownloadNumber自增 public Boolean DownloadNumberIncrement(int docId) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.Document dbDoc = (from doc in context.Documents where doc.Id.Equals(docId) select doc).FirstOrDefault(); dbDoc.DownloadNumber = dbDoc.DownloadNumber + 1; context.SaveChanges(); return true; }
public Boolean deleteDocumentById(int docid) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.Document dbDoc = (from doc in context.Documents where doc.Id.Equals(docid) select doc).FirstOrDefault(); context.DeleteObject(dbDoc); context.SaveChanges(); return true; }
public Boolean addNews(SiteNewsModel siteNewsModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.SiteNews siteNews = new DAL.SiteNews(); siteNews.Title = siteNewsModel.Title; siteNews.NewsContent = siteNewsModel.NewsContent; siteNews.PubTime = siteNewsModel.PubTime; siteNews.IsOnTop = siteNewsModel.IsOnTop; context.AddToSiteNews(siteNews); context.SaveChanges(); return true; }
public int CreateDepartment(DepartmentModel department) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Department dbDepartment = new Department { DepartmentName = department.DepartmentName, FolderId = department.FolderId }; context.Departments.AddObject(dbDepartment); context.SaveChanges(); return dbDepartment.Id; } }
public void DeleteDepartment(DepartmentModel department) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Department dbDept = (from d in context.Departments where d.Id == department.Id select d).FirstOrDefault(); if (dbDept != null) { context.Departments.DeleteObject(dbDept); context.SaveChanges(); } } }
public int CreateFolder(FolderModel folder) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Folder dbFolder = new Folder { FolderName = folder.FolderName, Description = folder.Description, ParentId = folder.ParentFolderId, PhysicalPath = folder.PhysicalPath }; context.Folders.AddObject(dbFolder); context.SaveChanges(); return dbFolder.Id; } }
public Boolean CreateUserAccount(UserEmployeeModel userEmployeeModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.UserEmployee userEmployee = ConvertToDB(userEmployeeModel); context.AddToUserEmployees(userEmployee); DAL.UserEmployeeDetail userDetail = new DAL.UserEmployeeDetail(); userDetail.Name = userEmployeeModel.Name; userDetail.Email = userEmployeeModel.Email; userDetail.EmployeeNumber = userEmployeeModel.EmployeeNumber; userDetail.Phone = userEmployeeModel.Phone; context.AddToUserEmployeeDetails(userDetail); context.SaveChanges(); return true; }
public int AddTag(string tagName) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Tag dbTag = new Tag { TagName = tagName }; try { context.AddToTags(dbTag); context.SaveChanges(System.Data.Objects.SaveOptions.DetectChangesBeforeSave); }catch(Exception e){ System.Diagnostics.Debug.WriteLine(e.InnerException.Message); } return dbTag.Id; } }
public void AddTagOfDoc(int tagId, int documentId) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { DocumentTag dbTagDoc = new DocumentTag { TagId = tagId, DocumentId = documentId }; try { context.AddToDocumentTags(dbTagDoc); context.SaveChanges(false); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.InnerException.Message); } } }
public int DeleteFolderCascade(FolderModel folder) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { folder.SubFolders = GetAllSubFolders(folder); // DFS遍历目录结构 Stack<FolderModel> folder_to_delete = new Stack<FolderModel>(); folder_to_delete.Push(folder); while (folder_to_delete.Count != 0) { FolderModel current = folder_to_delete.Pop(); foreach (FolderModel child in current.SubFolders) { folder_to_delete.Push(child); } Folder dbCurrent = ConvertModelToDB(current); context.Folders.Attach(dbCurrent); context.Folders.DeleteObject(dbCurrent); } return context.SaveChanges(); } }
public Boolean UpdateUserAccount(UserEmployeeModel userEmployeeModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); UserEmployeeDetail empDetal = (from d in context.UserEmployeeDetails where d.EmployeeNumber == userEmployeeModel.EmployeeNumber select d).FirstOrDefault(); empDetal.EmployeeNumber = userEmployeeModel.EmployeeNumber; empDetal.Name = userEmployeeModel.Name; empDetal.Email = userEmployeeModel.Email; empDetal.Phone = userEmployeeModel.Phone; context.SaveChanges(); UserEmployee emp = (from u in context.UserEmployees where u.EmployeeNumber == userEmployeeModel.EmployeeNumber select u).FirstOrDefault(); emp.EmployeeNumber = userEmployeeModel.EmployeeNumber; emp.Password = userEmployeeModel.Password; emp.DepartmentId = userEmployeeModel.DepartmentId; emp.IsManager = userEmployeeModel.IsManager; emp.IsAvailable = userEmployeeModel.IsAvailable; emp.IsChecker = userEmployeeModel.IsChecker; emp.LastLoginTime = userEmployeeModel.LastLoginTime; context.SaveChanges(); return true; }
//更新单个文档 public Boolean updateDocument(DocumentModel docModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.Document dbDoc = (from doc in context.Documents where doc.Id.Equals(docModel.Id) select doc).FirstOrDefault(); dbDoc.FileDisplayName = docModel.FileDisplayName; dbDoc.Description = docModel.Description; dbDoc.IsChecked = docModel.IsChecked; dbDoc.AuthLevel = docModel.AuthLevel; context.SaveChanges(); return true; }
public Boolean setDocUncheckedById(int docid) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.Document dbDoc = (from d in context.Documents where d.Id.Equals(docid) select d).FirstOrDefault(); dbDoc.IsChecked = false; context.SaveChanges(); return true; }
public Boolean UpdateUserDetailAccount(UserEmployeeDetailModel userEmployeeDetail) { geekinsidekmsEntities context = new geekinsidekmsEntities(); UserEmployeeDetail empDetal = (from d in context.UserEmployeeDetails where d.Id == userEmployeeDetail.Id select d).FirstOrDefault(); empDetal.EmployeeNumber = userEmployeeDetail.EmployeeNumber; empDetal.Name = userEmployeeDetail.Name; empDetal.Email = userEmployeeDetail.Email; empDetal.Phone = userEmployeeDetail.Phone; context.SaveChanges(); return true; }
public void UpdateDepartment(DepartmentModel department) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Department dbDepartment = new Department { Id = department.Id, DepartmentName = department.DepartmentName, FolderId = department.FolderId }; context.Departments.AddObject(dbDepartment); context.ObjectStateManager.ChangeObjectState(dbDepartment, EntityState.Modified); context.SaveChanges(); } }
public void UpdateFolder(FolderModel folder) { using (geekinsidekmsEntities context = new geekinsidekmsEntities()) { Folder dbFolder = ConvertModelToDB(folder); context.Folders.AddObject(dbFolder); context.ObjectStateManager.ChangeObjectState(dbFolder, EntityState.Modified); context.SaveChanges(); } }
public Boolean setItOnTopById(int id) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.SiteNews dbNews = (from news in context.SiteNews where news.Id.Equals(id) select news).FirstOrDefault(); dbNews.IsOnTop = true; context.SaveChanges(); return true; }
public Boolean updateNews(SiteNewsModel siteNewsModel) { geekinsidekmsEntities context = new geekinsidekmsEntities(); DAL.SiteNews dbNews = (from news in context.SiteNews where news.Id.Equals(siteNewsModel.Id) select news).FirstOrDefault(); dbNews.Title = siteNewsModel.Title; dbNews.NewsContent = siteNewsModel.NewsContent; dbNews.PubTime = siteNewsModel.PubTime; dbNews.IsOnTop = siteNewsModel.IsOnTop; context.SaveChanges(); return true; }