using System;
using System.ComponentModel;

namespace BeWo.Core
{
    public class DownloadLinkEngine : INotifyPropertyChanged
    {
        private string _ExcelFileId;

        private Uri _ExcelUri;

        private string _WordFileId;

        private Uri _WordUri;

        public DownloadLinkEngine()
        {
            this.GenerateNewExcelLink();
            this.GenerateNewWordLink();
        }

        public event PropertyChangedEventHandler PropertyChanged;

        public string ExcelFileId
        {
            get
            {
                return this._ExcelFileId;
            }
        }

        public Uri ExcelUri
        {
            get
            {
                return this._ExcelUri;
            }
        }

        public string WordFileId
        {
            get
            {
                return this._WordFileId;
            }
        }

        public Uri WordUri
        {
            get
            {
                return this._WordUri;
            }
        }

        public Uri GenerateNewExcelLink()
        {
            this._ExcelFileId = Guid.NewGuid() + ".xls";
            //alles nach dem ? wird beim klick auf word/excel export im jeweiligen view erstellt tenant=" + BeWoApp.Tenant + "&username=" + BeWoApp.UserName + "&token=" + BeWoApp.LoggedOnUser.RC2Password + "&
            this._ExcelUri = new Uri(BeWoApp.SiteOfOrigin + "/Download.aspx?fileid=" + this._ExcelFileId);

            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs("ExcelUri"));
            }

            return this._ExcelUri;
        }

        public Uri GenerateNewWordLink()
        {
            this._WordFileId = Guid.NewGuid() + ".doc";
                                                                         //alles nach dem ? wird beim klick auf word/excel export im jeweiligen view erstellt
            this._WordUri = new Uri(BeWoApp.SiteOfOrigin + "/Download.aspx?tenant=" + BeWoApp.Tenant + "&username=" + BeWoApp.UserName + "&token=" + BeWoApp.LoggedOnUser.RC2Password + "&fileid=" + this._WordFileId);

            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs("WordUri"));
            }

            return this._WordUri;
        }
    }
}