<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Portfolio.API.Data;
using Portfolio.API.Data.Entity;
using Portfolio.API.Manager;
using Portfolio.API.ViewModel;

namespace Portfolio.API.Controllers
{

    [Route("api/contactmessage")]
    public class ContactMessageController : Controller
    {

        private readonly ContactMessageManager _contactMessageManager;

        public ContactMessageController(DataContext dataContext)
        {
            _contactMessageManager = new ContactMessageManager(dataContext);
        }

        [HttpGet]
        public JsonResponse<IEnumerable<ContactMessage>> GetAll()
        {
            return new JsonResponse<IEnumerable<ContactMessage>>()
            {
                Data = _contactMessageManager.Get(),
                ErrorMessage = null
            };
        }

        [HttpPost]
        public JsonResponse<bool> Add([FromBody]ContactMessageViewModel message)
        {
            try
            {
                var remoteAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
                _contactMessageManager.Add(message, remoteAddress);
                return new JsonResponse<bool>()
                {
                    Data = true,
                    ErrorMessage = null
                };
            }
            catch (ManagerException e)<commit_msg>Removed the controller end point to return all messages<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Portfolio.API.Data;
using Portfolio.API.Data.Entity;
using Portfolio.API.Manager;
using Portfolio.API.ViewModel;

namespace Portfolio.API.Controllers
{

    [Route("api/contactmessage")]
    public class ContactMessageController : Controller
    {

        private readonly ContactMessageManager _contactMessageManager;

        public ContactMessageController(DataContext dataContext)
        {
            _contactMessageManager = new ContactMessageManager(dataContext);
        }

        [HttpPost]
        public JsonResponse<bool> Add([FromBody]ContactMessageViewModel message)
        {
            try
            {
                var remoteAddress = Request.HttpContext.Connection.RemoteIpAddress.ToString();
                _contactMessageManager.Add(message, remoteAddress);
                return new JsonResponse<bool>()
                {
                    Data = true,
                    ErrorMessage = null
                };
            }
            catch (ManagerException e)
{'fraction_non_alphanumeric': 0.07428355957767722, 'fraction_numerical': 0.0, 'mean_word_length': 2.2353658536585366, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5322570', 'n_tokens_mistral': 629, 'n_tokens_neox': 610, 'n_words': 130}