/**
 * (c) by aheadware.com
 */
"use strict";

var app = app || {};
app.model = app.model || {};

/**
 * Message Model
 */
app.model.Message = function( data )
{
    var id = data.id,
        creatorId = data.creator_id || null,
        creatorFirstName = data.first_name || null,
        creatorLastName = data.last_name || null,
        creatorPicUrl = data.pic_url || null,
        conversationId = data.conversation_id || null,
        subject = data.subject || null,
        message = data.message || null,
        mCreated = app.util.Helper.getMomentFromUTCTime(data.created_dt),
        mLastUpdated = app.util.Helper.getMomentFromUTCTime(data.last_updated_dt),
        isRead = data.is_read || 0;

    this.getId = function()
    {
        return id;
    };

    this.getCreatorName = function()
    {
        var name = '<strong>Pro</strong>Buddy';

        if ( creatorId != null && 0 < creatorId )
        {
            if ( creatorFirstName && creatorFirstName.length )
            {
                name = creatorFirstName;
                if ( creatorLastName && creatorLastName.length )
                {
                    name = name + " " + creatorLastName;
                }
            }
            else if ( creatorLastName && creatorLastName.lengt )
            {
                name = creatorLastName;
            }
        }

        return name;
    };

    this.getCreatorPicUrl = function()
    {
        return './img-system/logo-blue.png';
    };

    this.getSubject = function()
    {
        return subject;
    };

    this.getMessage = function()
    {
        return message;
    };

    this.isRead = function()
    {
        return ( 1 == isRead );
    };

    this.getMomentCreated = function()
    {
        return mCreated;
    };
};