<commit_before>﻿using IDEIMusic.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Web.Helpers;

namespace IDEIMusic
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WebService
    {

        LabelContext db = new LabelContext();

        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
        [OperationContract]
        public void DoWork()
        {
            // Add your operation implementation here
            return;
        }

        // Add more operations here and mark them with [OperationContract]

        [OperationContract]
        public string verifyAPI(string inputJSON)
        {
            string j = Json.Decode(inputJSON);

            string result = "fail";
            if (true)
            {
                result = "OK";
            }

            return result;

        }

        [OperationContract]
        public string getAllAbums()
        {
            return Json.Encode(db.Albums.ToList());
        }

        [OperationContract]
        public string RegisterSale(string inputJSON)
        {
            string j = Json.Decode(inputJSON);<commit_msg>Adicionado método que devolve a api_key a ser usado pela MusicStore aquando de um primeiro contacto do Admin correspondente<commit_after>﻿using IDEIMusic.DAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.ServiceModel.Web;
using System.Text;
using System.Web.Helpers;
using IDEIMusic.Models;

namespace IDEIMusic
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class WebService
    {

        LabelContext db = new LabelContext();

        // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
        // To create an operation that returns XML,
        //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
        //     and include the following line in the operation body:
        //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
        [OperationContract]
        public void DoWork()
        {
            // Add your operation implementation here
            return;
        }

        // Add more operations here and mark them with [OperationContract]

        [OperationContract]
        public string verifyAPI(string inputJSON)
        {
            string j = Json.Decode(inputJSON);

            string result = "fail";
            if (true)
            {
                result = "OK";
            }

            return result;

        }

        [OperationContract]
        public string firstContact(string inputJSON)
        {
            var j = Json.Decode(inputJSON);

            string userName = j["UserEmail"];
            var user = db.Users.Where(a => a.UserEmail.Equals(userName)).FirstOrDefault();

            string result = "fail";

            if(user != null)
            {
                if (user is Store)
                {
                    Store a = (Store)user;
                    result = a.store_api_key.ToString();
                }
            }

            return result;
        }

        [OperationContract]
        public string getAllAbums()
        {
            return Json.Encode(db.Albums.ToList());
        }

        [OperationContract]
        public string RegisterSale(string inputJSON)
        {
            string j = Json.Decode(inputJSON);
{'fraction_non_alphanumeric': 0.0829303675048356, 'fraction_numerical': 0.0, 'mean_word_length': 2.0329912023460412, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2871755', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1025, 'n_words': 276}