(function() {

    'use strict';
    
    app.factory('comment.repository', ['WebApi', '$http', function(WebApi, $http) {
        return {
            getComments: _getComments,
            addComment: _addComment,
            deleteComment: _deleteComment,
            editComment: _editComment,
            deleteSecondComment: _deleteSecondComment,
            editSecondComment: _editSecondComment,
            commentReply: _commentReply
        };
        function _getComments(){
            return $http.get(WebApi.DOMAIN + '/comments');
        };
        function _addComment(data){
            return $http.post(WebApi.DOMAIN + '/addComment', data);
        };
        function _deleteComment(id){
            return $http.delete(WebApi.DOMAIN + '/deleteComment/' + id);
        };
        function _editComment(data){
            return $http.put(WebApi.DOMAIN + '/editComment/', data);
        };
        function _deleteSecondComment(mainId, secondId){
            return $http.delete(WebApi.DOMAIN + '/deleteSecondComment/' + mainId + '/' + secondId);
        };
        function _commentReply(data){
            return $http.post(WebApi.DOMAIN + '/commentReply', data);
        };
        function _editSecondComment(data){
            return $http.put(WebApi.DOMAIN + '/editSecondComment/', data);
        };
    }])
})()