<commit_before>﻿namespace Telerickr.Services.Controllers
{
    using System.Linq;
    using System.Web.Http;
    
    using Data;
    using Models.Comments;
    using Telerickr.Models;
    
    public class CommentsController : ApiController
    {
        private readonly IRepository<Photo> photos;
        private readonly IRepository<Comment> comments;

        public CommentsController(IRepository<Comment> comments, IRepository<Photo> photos)
        {
            this.comments = comments;
            this.photos = photos;
        }

        public IHttpActionResult Get()
        {
            var result = this.comments
                .All()
                .OrderBy(p => p.Id)
                .Take(10)
                .Select(CommentResponseModel.FromModel)
                .ToList();

            return this.Ok(result);
        }

        public IHttpActionResult Get(int id)
        {
            var result = this.comments
                .All()
                .Where(c => c.Id == id)
                .Select(CommentResponseModel.FromModel)
                .FirstOrDefault();

            if (result == null)
            {
                return this.NotFound();
            }

            return this.Ok(result);
        }<commit_msg>Replaced magic number with constant.<commit_after>﻿namespace Telerickr.Services.Controllers
{
    using System.Linq;
    using System.Web.Http;

    using Data;
    using Models.Comments;
    using Telerickr.Models;
    using Common;

    public class CommentsController : ApiController
    {
        private readonly IRepository<Photo> photos;
        private readonly IRepository<Comment> comments;

        public CommentsController(IRepository<Comment> comments, IRepository<Photo> photos)
        {
            this.comments = comments;
            this.photos = photos;
        }

        public IHttpActionResult Get()
        {
            var result = this.comments
                .All()
                .OrderBy(p => p.Id)
                .Take(GlobalConstants.DefaultPageSize)
                .Select(CommentResponseModel.FromModel)
                .ToList();

            return this.Ok(result);
        }

        public IHttpActionResult Get(int id)
        {
            var result = this.comments
                .All()
                .Where(c => c.Id == id)
                .Select(CommentResponseModel.FromModel)
                .FirstOrDefault();

            if (result == null)
            {
                return this.NotFound();
            }

            return this.Ok(result);
        }
{'fraction_non_alphanumeric': 0.08605919003115264, 'fraction_numerical': 0.000778816199376947, 'mean_word_length': 1.4965986394557824, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '136827', 'n_tokens_mistral': 668, 'n_tokens_neox': 630, 'n_words': 140}