예제 #1
0
 public List<FavoriteModel> getFavoriteDocListByEmployeeNumber(int empNumber)
 {
     using (var gikms = new geekinsidekmsEntities())
     {
         var dbFav = from f in gikms.Favorites
                       where f.EmployeeNumber.Equals(empNumber)
                       select f;
         List<DAL.Favorite> favdocTempList = dbFav.ToList();
         if (favdocTempList.Count == 0)
         {
             return null;
         }
         List<FavoriteModel> favDocModelList = new List<FavoriteModel>();
         foreach (Favorite fav in favdocTempList)
         {
             favDocModelList.Add(new FavoriteModel
             {
                 Id = fav.Id,
                 EmployeeNumber = fav.EmployeeNumber,
                 DocumentId = fav.DocumentId
             });
         }
         return favDocModelList;
     }
 }
예제 #2
0
 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;
     }
 }
예제 #3
0
        //get all 默认按置顶和时间排序
        public List<SiteNewsModel> getAll(int pageNumber,int pageSize)
        {
            using (var gikms = new geekinsidekmsEntities())
            {
                var siteNewsList = from n in gikms.SiteNews
                                   orderby n.IsOnTop descending
                                   select n;

                int totalCount = siteNewsList.Count();
                var siteNewsListPaged = (from n in siteNewsList
                                         select n).Skip((pageNumber-1)*pageSize).Take(pageSize);

                List<DAL.SiteNews> newsTempList = siteNewsListPaged.ToList();
                List<SiteNewsModel> newsList = new List<SiteNewsModel>();
                foreach (DAL.SiteNews nm in newsTempList)
                {
                    newsList.Add(new SiteNewsModel{
                        Id = nm.Id,
                        Title = nm.Title,
                        NewsContent = nm.NewsContent,
                        PubTime = nm.PubTime,
                        IsOnTop = nm.IsOnTop
                    });
                }
                return newsList;
            }
        }
예제 #4
0
 public int GetFileTypeId(string fileTypeName)
 {
     using (var gikms = new geekinsidekmsEntities())
     {
         int id = (from f in gikms.FileTypes
                   where f.TypeName.Equals(fileTypeName)
                       select f.Id).FirstOrDefault();
         return id;
     }
 }
예제 #5
0
 public UserAdminModel getUserByUsername(string username)
 {
     using (var gikms = new geekinsidekmsEntities())
     {
         UserAdmin dbAdmin = (from u in gikms.UserAdmins
                                    where u.Username.Equals(username)
                                    select u).FirstOrDefault();
         return ConvertFromDB(dbAdmin);
     }
 }
예제 #6
0
 public void DeleteFolder(FolderModel folder)
 {
     using (geekinsidekmsEntities context =
         new geekinsidekmsEntities())
     {
         Folder dbFolder = ConvertModelToDB(folder);
         context.Folders.Attach(dbFolder);
         context.Folders.DeleteObject(dbFolder);
         context.SaveChanges();
     }
 }
예제 #7
0
        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;
        }
예제 #8
0
        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;
        }
예제 #9
0
        //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;
        }
예제 #10
0
        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;
        }
예제 #11
0
        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;
        }
예제 #12
0
 public DepartmentModel GetDepartmentById(int dept_id)
 {
     using (geekinsidekmsEntities context =
        new geekinsidekmsEntities())
     {
         Department dbDepartment = (from d in context.Departments
                                    where d.Id == dept_id
                                    select d).FirstOrDefault();
         if (dbDepartment == null) return null;
         return ConvertFromDB(dbDepartment);
     }
 }
예제 #13
0
        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;
        }
예제 #14
0
 public IList<DepartmentModel> GetAllDepartments()
 {
     IList<DepartmentModel> result = new List<DepartmentModel>();
     using (geekinsidekmsEntities context =
        new geekinsidekmsEntities())
     {
         var list = from d in context.Departments select d;
         foreach (Department dbDept in list)
         {
             result.Add(ConvertFromDB(dbDept));
         }
         return result;
     }
 }
예제 #15
0
        public UserEmployeeModel GetSingleEmployeeDetailById(int id)
        {
            using (var gikms = new geekinsidekmsEntities())
            {
                UserEmployeeDetail dbUserDetail = (from u in gikms.UserEmployeeDetails
                                             where u.Id.Equals(id)
                                             select u).FirstOrDefault();

                UserEmployee dbUser = (from u in gikms.UserEmployees
                                             where u.Id.Equals(id)
                                             select u).FirstOrDefault();

                return ConvertFromDB(dbUser , dbUserDetail);
            }
        }
예제 #16
0
        public int GetMaxEmployeeNumber()
        {
            geekinsidekmsEntities context = new geekinsidekmsEntities();

            var allEmp = from emp in context.UserEmployees select emp;

            int maxEmpNumber = 999;

            if (allEmp.Count() != 0)
            {
                maxEmpNumber = (from max in allEmp select max.EmployeeNumber).Max();
            }

            return maxEmpNumber;
        }
예제 #17
0
 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();
         }
     }
 }
예제 #18
0
 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;
     }
 }
예제 #19
0
 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();
     }
 }
예제 #20
0
파일: DALTag.cs 프로젝트: Weej1/geekinside
 public int[] getTagIdArrayByDocId(int docid)
 {
     using (var gikms = new geekinsidekmsEntities())
     {
         var dbTags = from t in gikms.DocumentTags
                      where t.DocumentId.Equals(docid)
                      select t;
         List<DAL.DocumentTag> tagsTempList = dbTags.ToList();
         int[] tagIdArray = new int[tagsTempList.Count];
         for (int i = 0; i < tagsTempList.Count;i++ )
         {
             tagIdArray[i] = tagsTempList[i].TagId;
         }
         return tagIdArray;
     }
 }
예제 #21
0
 public List<UserEmployeeModel> GetAllEmployeeDetails()
 {
     List<UserEmployeeModel> userEmpDetails = new List<UserEmployeeModel>();
     using (var gikms = new geekinsidekmsEntities())
     {
         var emps = from d in gikms.UserEmployees
                          select d;
         if (emps.Count() != 0)
         {
             foreach (UserEmployee temp in emps)
             {
                 userEmpDetails.Add(GetSingleEmployeeDetail(temp.EmployeeNumber));
             }
         }
         return userEmpDetails;
     }
 }
예제 #22
0
        public UserEmployeeDetailModel GetEmployeeDetailByEmployeeNumber(int employeeNumber)
        {
            geekinsidekmsEntities context = new geekinsidekmsEntities();

            UserEmployeeDetail dbDetail = (from detail in context.UserEmployeeDetails
                                           where detail.EmployeeNumber == employeeNumber
                                           select detail).FirstOrDefault();

            UserEmployeeDetailModel empDetail = new UserEmployeeDetailModel();
            empDetail.Id = dbDetail.Id;
            empDetail.EmployeeNumber = dbDetail.EmployeeNumber;
            empDetail.Name = dbDetail.Name;
            empDetail.Email = dbDetail.Email;
            empDetail.Phone = dbDetail.Phone;

            return empDetail;
        }
예제 #23
0
        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;
        }
예제 #24
0
파일: DALTag.cs 프로젝트: Weej1/geekinside
        public int GetTagIdByTagName(string tagName)
        {
            using (var gikms = new geekinsidekmsEntities())
            {

                try
                {
                    var tagId = (from tn in gikms.Tags
                               where tn.TagName.Equals(tagName)
                               select tn.Id).FirstOrDefault();
                    return tagId;
                }catch(Exception e){
                    System.Diagnostics.Debug.WriteLine(e.InnerException.Message);
                    return 0;
                }
            }
        }
예제 #25
0
 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;
     }
 }
예제 #26
0
파일: DALTag.cs 프로젝트: Weej1/geekinside
 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;
     }
 }
예제 #27
0
 public List<UserEmployeeModel> GetEmployeeDetailsByDept(int deptId)
 {
     List<UserEmployeeModel> userEmpDetails = new List<UserEmployeeModel>();
     using (var gikms = new geekinsidekmsEntities())
     {
         var emps = from d in gikms.UserEmployees
                    where d.DepartmentId == deptId
                    select d;
         if (emps.Count() != 0)
         {
             foreach (UserEmployee temp in emps)
             {
                 userEmpDetails.Add(GetSingleEmployeeDetail(temp.EmployeeNumber));
             }
         }
         return userEmpDetails;
     }
 }
예제 #28
0
        public List<DocumentModel> getAllCheckedByPublisherNumber(int publisherNumber)
        {
            using (var gikms = new geekinsidekmsEntities())
            {
                var dbDocList = from d in gikms.Documents
                                where d.PublisherNumber.Equals(publisherNumber) && d.IsChecked.Equals(true)
                                select d;

                if (dbDocList == null)
                {
                    return null;
                }

                List<DAL.Document> docTempList = dbDocList.ToList();
                //生成最终List
                return gernerateFinalDocumentModelList(docTempList);
            }
        }
예제 #29
0
        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;
        }
예제 #30
0
 public SiteNewsModel getNewsById(int id)
 {
     using (var gikms = new geekinsidekmsEntities())
     {
         SiteNews dbNews = (from n in gikms.SiteNews
                              where n.Id.Equals(id)
                              select n).FirstOrDefault();
         if (dbNews == null)
             return null;
         return new SiteNewsModel
         {
             Id = dbNews.Id,
             Title = dbNews.Title,
             NewsContent = dbNews.NewsContent,
             IsOnTop = dbNews.IsOnTop,
             PubTime = dbNews.PubTime
         };
     }
 }