using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BankTVUpdater.Logger;

namespace BankTVUpdater.Model.Service
{
    class SingleFile : AbstractModel
    {
        public int Id { get; set; }
        public string FileHost { get; set; }
        public string FileDirectory { get; set; }
        public string FileName { get; set; }
        public string MimeType { get; set; }
        public string Checksum { get; set; }
        public decimal Size { get; set; }
        public int ScreenId { get; set; }

        public void SetAndConvertSize(string size)
        {
            try
            {
                if (String.IsNullOrEmpty(size))
                {
                    this.Size = -1;
                    return;
                }   //if
                this.Size = decimal.Parse(size);
            }   //try
            catch (Exception ex)
            {
                MyLogger.Log(ex);
                this.Size = -1;
            }   //catch
        }

        public string GetFilePath()
        {
            if ((String.IsNullOrEmpty(this.FileDirectory)) 
                || (String.IsNullOrEmpty(this.FileName)) 
                || (String.IsNullOrEmpty(this.FileHost)))
            {
                return String.Empty;
            }   //if
            return this.FileHost + this.FileDirectory + this.FileName;
        }
    }
}
