示例#1
0
        public void RemoveCollection(int CollectionID)
        {
            CollectionModel collectionToRemove = GetCollectionById(CollectionID);

            LinqAdapter.GetTable <CollectionModel>().DeleteOnSubmit(collectionToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#2
0
        public void RemoveRequest(int RequestID)
        {
            RequestModel requestToRemove = GetRequestById(RequestID);

            LinqAdapter.GetTable <RequestModel>().DeleteOnSubmit(requestToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#3
0
        public int AddComment(int UserID, Nullable <int> DocumentID, Nullable <int> CollectionID, String CommentContent)
        {
            CommentModel commentToInsert = new CommentModel();

            commentToInsert.UserID = UserID;
            if (DocumentID == 0)
            {
                commentToInsert.DocumentID = null;
            }
            else
            {
                commentToInsert.DocumentID = DocumentID;
            }
            if (CollectionID == 0)
            {
                commentToInsert.CollectionID = null;
            }
            else
            {
                commentToInsert.CollectionID = CollectionID;
            }
            commentToInsert.CommentContent = CommentContent;

            LinqAdapter.GetTable <CommentModel>().InsertOnSubmit(commentToInsert);
            LinqAdapter.SubmitChanges();

            return(commentToInsert.CommentID);
        }
示例#4
0
        public void RemoveCategory(int CategoryID)
        {
            CategoryModel categoryToRemove = GetCategoryById(CategoryID);

            LinqAdapter.GetTable <CategoryModel>().DeleteOnSubmit(categoryToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#5
0
        public void AddTag(String TagName, Nullable <int> DocumentID, Nullable <int> CollectionID)
        {
            ConvertLetter cv    = new ConvertLetter();
            String        Alias = cv.ClearAccent(TagName);

            TagsModel tagToInsert = new TagsModel();

            if (DocumentID == 0)
            {
                tagToInsert.DocumentID = null;
            }
            else
            {
                tagToInsert.DocumentID = DocumentID;
            }
            if (CollectionID == 0)
            {
                tagToInsert.CollectionID = null;
            }
            else
            {
                tagToInsert.CollectionID = CollectionID;
            }
            tagToInsert.TagName = TagName;
            tagToInsert.Alias   = Alias;

            LinqAdapter.GetTable <TagsModel>().InsertOnSubmit(tagToInsert);
            LinqAdapter.SubmitChanges();
        }
示例#6
0
        public void RemoveTag(int TagID)
        {
            TagsModel tagToRemove = GetTagById(TagID);

            LinqAdapter.GetTable <TagsModel>().DeleteOnSubmit(tagToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#7
0
        public int AddDocument(String Name, String Description, String Thumbnails, String Link, int FileSize, int UserID, int CategoryID, Nullable <int> CollectionID)
        {
            ConvertLetter cvLetter = new ConvertLetter();
            String        Alias    = cvLetter.ClearAccent(Name).ToTitleCase().Replace(" ", "");

            DocumentModel documentToInsert = new DocumentModel();

            documentToInsert.UserID = UserID;
            if (CollectionID == 0)
            {
                documentToInsert.CollectionID = null;
            }
            else
            {
                documentToInsert.CollectionID = CollectionID;
            }
            documentToInsert.CategoryID       = CategoryID;
            documentToInsert.Name             = Name;
            documentToInsert.Alias            = Alias;
            documentToInsert.Description      = Description;
            documentToInsert.Thumbnails       = Thumbnails;
            documentToInsert.TotalView        = 0;
            documentToInsert.TotalDownload    = 0;
            documentToInsert.UploadDate       = DateTime.Now;
            documentToInsert.Link             = Link;
            documentToInsert.FileSize         = FileSize;
            documentToInsert.IsError          = false;
            documentToInsert.ErrorReportCount = 0;

            LinqAdapter.GetTable <DocumentModel>().InsertOnSubmit(documentToInsert);
            LinqAdapter.SubmitChanges();

            return(documentToInsert.DocumentID);
        }
示例#8
0
        public double DocumentAverageRate(int DocumentID)
        {
            IEnumerable <DocumentRatingModel> documentRate = LinqAdapter.GetTable <DocumentRatingModel>().Where(r => r.DocumentID == DocumentID).ToList();
            dynamic documentVotes = documentRate.Select(r => new { r.Rate, Votes = 1 }).GroupBy(r => r.Rate).Count();

            return(0.0);
        }
示例#9
0
        public void RemoveDocument(int DocumentID)
        {
            DocumentModel documentToRemove = GetDocumentById(DocumentID);

            LinqAdapter.GetTable <DocumentModel>().DeleteOnSubmit(documentToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#10
0
        public void RemoveGroup(int GroupID)
        {
            GroupModel groupToRemove = GetGroupById(GroupID);

            LinqAdapter.GetTable <GroupModel>().DeleteOnSubmit(groupToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#11
0
        public void RemoveFeedback(int FeedbackID)
        {
            FeedbackModel feedbackToRemove = GetFeedbackById(FeedbackID);

            LinqAdapter.GetTable <FeedbackModel>().DeleteOnSubmit(feedbackToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#12
0
        public void RemoveUser(int UserID)
        {
            UsersModel userToRemove = GetUserById(UserID);

            LinqAdapter.GetTable <UsersModel>().DeleteOnSubmit(userToRemove);
            LinqAdapter.SubmitChanges();
        }
示例#13
0
        public void UpdateRate(int DocumentID, int UserID, int Rate)
        {
            DocumentRatingModel documentRatingToUpdate = LinqAdapter.GetTable <DocumentRatingModel>().Single(r => r.DocumentID == DocumentID && r.UserID == UserID);

            documentRatingToUpdate.Rate = Rate;

            LinqAdapter.SubmitChanges();
        }
示例#14
0
        public void AddRequest(String Content, int UserID)
        {
            RequestModel requestToInsert = new RequestModel();

            requestToInsert.RequestContent = Content;
            requestToInsert.UserID         = UserID;
            requestToInsert.RequestDate    = DateTime.Now;

            LinqAdapter.GetTable <RequestModel>().InsertOnSubmit(requestToInsert);
            LinqAdapter.SubmitChanges();
        }
示例#15
0
        public void AddFeedback(String Sender, String Email, String Content)
        {
            FeedbackModel feedbackToIsert = new FeedbackModel();

            feedbackToIsert.Sender          = Sender;
            feedbackToIsert.Email           = Email;
            feedbackToIsert.FeedbackContent = Content;
            feedbackToIsert.FeedbackDate    = DateTime.Now;

            LinqAdapter.GetTable <FeedbackModel>().InsertOnSubmit(feedbackToIsert);
            LinqAdapter.SubmitChanges();
        }
示例#16
0
        public int AddRate(int DocumentID, int UserID, int Rate)
        {
            DocumentRatingModel documentRatingToInsert = new DocumentRatingModel();

            documentRatingToInsert.DocumentID = DocumentID;
            documentRatingToInsert.UserID     = UserID;
            documentRatingToInsert.Rate       = Rate;

            LinqAdapter.GetTable <DocumentRatingModel>().InsertOnSubmit(documentRatingToInsert);
            LinqAdapter.SubmitChanges();

            return(documentRatingToInsert.RateID);
        }
示例#17
0
        public void AddCategory(String Name)
        {
            ConvertLetter cvLetter = new ConvertLetter();
            String        Alias    = cvLetter.ClearAccent(Name).ToTitleCase().Replace(" ", "");

            CategoryModel categoryToInsert = new CategoryModel();

            categoryToInsert.Name  = Name;
            categoryToInsert.Alias = Alias;

            LinqAdapter.GetTable <CategoryModel>().InsertOnSubmit(categoryToInsert);
            LinqAdapter.SubmitChanges();
        }
示例#18
0
        public void AddGroup(String Name, String Description, bool IsLimt, int DownloadLimit)
        {
            GroupModel groupToInsert = new GroupModel();

            groupToInsert.Name          = Name;
            groupToInsert.Description   = Description;
            groupToInsert.IsAdmin       = false;
            groupToInsert.IsDefault     = false;
            groupToInsert.IsLimit       = IsLimit;
            groupToInsert.DownloadLimit = DownloadLimit;

            LinqAdapter.GetTable <GroupModel>().InsertOnSubmit(groupToInsert);
            LinqAdapter.SubmitChanges();
        }
示例#19
0
        public IEnumerable <DocumentModel> SearchDocumentByCollectionName(String CollectionName)
        {
            IEnumerable <CollectionModel> collection = LinqAdapter.GetTable <CollectionModel>();
            IEnumerable <DocumentModel>   doc        = LinqAdapter.GetTable <DocumentModel>();

            IEnumerable <DocumentModel> result = from c in collection
                                                 join d in doc
                                                 on c.CollectionID equals d.UserID
                                                 //where SqlMethods.Like(c.Name, "%" + CollectionName + "%")
                                                 where c.Name.Like("*" + CollectionName + "*")
                                                 select d;

            return(result.ToList());
        }
示例#20
0
        public IEnumerable <DocumentModel> SearchDocumentByUsername(String Username)
        {
            IEnumerable <UsersModel>    user = LinqAdapter.GetTable <UsersModel>();
            IEnumerable <DocumentModel> doc  = LinqAdapter.GetTable <DocumentModel>();

            IEnumerable <DocumentModel> result = from u in user
                                                 join d in doc
                                                 on u.UserID equals d.UserID
                                                 //where SqlMethods.Like(u.Username, "%" + Username + "%")
                                                 where u.Username.Like("*" + Username + "*")
                                                 select d;

            return(result.ToList());
        }
示例#21
0
        public void AddUser(String Username, String Password, String Email, int GroupID)
        {
            UsersModel userToInsert = new UsersModel();

            userToInsert.Username    = Username;
            userToInsert.Password    = Password;
            userToInsert.Email       = Email;
            userToInsert.Point       = 0;
            userToInsert.TotalUpload = 0;
            userToInsert.GroupID     = GroupID;

            LinqAdapter.GetTable <UsersModel>().InsertOnSubmit(userToInsert);
            LinqAdapter.SubmitChanges();
        }
示例#22
0
        public int AddCollection(String Name, String Description, int UserID)
        {
            ConvertLetter cvLetter = new ConvertLetter();
            String        Alias    = cvLetter.ClearAccent(Name).ToTitleCase().Replace(" ", "_");

            CollectionModel collectionToInsert = new CollectionModel();

            collectionToInsert.UserID      = UserID;
            collectionToInsert.Name        = Name;
            collectionToInsert.Alias       = Alias;
            collectionToInsert.Description = Description;
            collectionToInsert.TotalView   = 0;
            collectionToInsert.CreatedDate = DateTime.Now;
            collectionToInsert.IsError     = false;

            LinqAdapter.GetTable <CollectionModel>().InsertOnSubmit(collectionToInsert);
            LinqAdapter.SubmitChanges();

            return(collectionToInsert.CollectionID);
        }
示例#23
0
 public PreferencesModel GetPreferencesByName(String Name)
 {
     return(LinqAdapter.GetTable <PreferencesModel>().SingleOrDefault(p => p.Name == Name));
 }
示例#24
0
 public PreferencesModel GetPreferencesById(int PreferencesID)
 {
     return(LinqAdapter.GetTable <PreferencesModel>().SingleOrDefault(p => p.PreferencesID == PreferencesID));
 }
示例#25
0
 public IEnumerable <DocumentModel> GetDocumentList()
 {
     return(LinqAdapter.GetTable <DocumentModel>().ToList());
 }
示例#26
0
 public IEnumerable <DocumentModel> SearchDocumentByName(String Name)
 {
     return(LinqAdapter.GetTable <DocumentModel>().Where(d => SqlMethods.Like(d.Name, "%" + Name + "%")).ToList());
 }
示例#27
0
 public IEnumerable <DocumentModel> GetDocumentByCategoryID(int CategoryID)
 {
     return(LinqAdapter.GetTable <DocumentModel>().Where(d => d.CategoryID == CategoryID).ToList());
 }
示例#28
0
 public IEnumerable <DocumentModel> GetDocumentHasError()
 {
     return(LinqAdapter.GetTable <DocumentModel>().Where(d => d.IsError == true));
 }
示例#29
0
 public IEnumerable <DocumentModel> GetDocumentByUserId(int UserID)
 {
     return(LinqAdapter.GetTable <DocumentModel>().Where(d => d.UserID == UserID));
 }
示例#30
0
 public DocumentModel GetDocumentById(int DocumentID)
 {
     return(LinqAdapter.GetTable <DocumentModel>().SingleOrDefault(d => d.DocumentID == DocumentID));
 }