<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Skermstafir.Models;

namespace Skermstafir.Repositories
{
    public class RequestRepository
    {
        // adds new request to database
        public void AddRequest(RequestModel newRequest)
        {

        }

        //deletes a request with a specific id
        public void DeleteRequest(int id)
        {

        }

        // queries and gets requests starting from index start and ending at index end
        public RequestModelList GetRequestByNewest(int start, int end)
        {
            RequestModelList modelList = new RequestModelList();
     
            return modelList;
        }

        // queries database and gets most popular requests starting at index start and ending at index end
        public RequestModelList GetByMostPopular(int start, int end)
        {
            RequestModelList modelList = new RequestModelList();
            return modelList;
        }

        // queries database and gets all requests from a specific user starting at index start and ending at index end both inclusive
        public RequestModelList GetRequestByUser(String username, int start, int end)
        {
            SkermData db = new SkermData();
            RequestModelList modelList = new RequestModelList();
            return modelList;
        }

        // queries and gets a request by id
        public RequestModel GetRequestByID(int id)
        {
            SkermData db = new SkermData();
            RequestModel dummy = new RequestModel();
            dummy.request = (from req in db.Requests
                             where req.IdRequest == id
                             select req).Single();
            dummy.votes = dummy.request.Votes.Count;
            return dummy;
        }
        // queries database and gets request in language starting at index start and ending at index end both inclusive
        public RequestModelList GetRequestByLanguage(String language, int start, int end)
        {
            RequestModelList modelList = new RequestModelList();
            return modelList;
        }

    }
}<commit_msg>Request Repo Almost Ready Baby!<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Skermstafir.Models;

namespace Skermstafir.Repositories
{
    public class RequestRepository
    {
        // adds new request to database
        public void AddRequest(RequestModel newRequest)
        {
        }

        //deletes a request with a specific id
        public void DeleteRequest(int id)
        {

        }

        // queries and gets requests starting from index start and ending at index end
        public RequestModelList GetRequestByNewest(int start, int end)
        {
            RequestModelList model = new RequestModelList();
            using (SkermData db = new SkermData())
            {
                model.modelList = (from req in db.Requests
                                   orderby req.DateAdded
                                   select req).Skip(start).Take(end - start).ToList();
            }
            return model;
        }

        // queries database and gets most popular requests starting at index start and ending at index end
        public RequestModelList GetByMostPopular(int start, int end)
        {
            RequestModelList model = new RequestModelList();
            using (SkermData db = new SkermData())
            {
                model.modelList = (from req in db.Requests
                                   orderby req.Votes.Count
                                   select req).Skip(start).Take(end - start).ToList();
            }
            return model;
        }

        // queries database and gets all requests from a specific user starting at index start and ending at index end both inclusive
        public RequestModelList GetRequestByUser(String username, int start, int end)
        {
            RequestModelList model = new RequestModelList();
            using (SkermData db = new SkermData())
            {
                model.modelList = (from req in db.Requests
                                   where req.Username == username
                                   orderby req.IdRequest
                                   select req).Skip(start).Take(end - start).ToList();
            }
            return model;
        }

        // queries and gets a request by id
        public RequestModel GetRequestByID(int id)
        {
            RequestModel model = new RequestModel();
            using (SkermData db = new SkermData())
            {
                model.request = (from req in db.Requests
                                 where req.IdRequest == id
                                 select req).Single();
                model.votes = model.request.Votes.Count;
            }
            return model;
        }
        // queries database and gets request in language starting at index start and ending at index end both inclusive
        public RequestModelList GetRequestByLanguage(String language, int start, int end)
        {
            RequestModelList modelList = new RequestModelList();
            using (SkermData db = new SkermData())
            {
                modelList.modelList = (from req in db.Requests
                                       where req.Language.Name == language
                                       orderby req.IdRequest
                                       select req).Skip(start).Take(end - start).ToList();
            }
            return modelList;
        }
    }
}
{'fraction_non_alphanumeric': 0.06028368794326241, 'fraction_numerical': 0.0, 'mean_word_length': 1.5959502991256327, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3097451', 'n_tokens_mistral': 1291, 'n_tokens_neox': 1264, 'n_words': 451}