using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UMinho.GestaoProjectos.DataAccess; /// ficheiro designer
using System.Transactions;
using System.Collections;
using UMinho.GestaoProjectos.Config;

/// Template File

namespace UMinho.GestaoProjectos.BLL
{
    public class BLLTemplateFile
    {
        public TemplateFile GetFile()
        {
            using (GestaoProjectosEntities lt = new GestaoProjectosEntities())
            {
                return lt.TemplateFiles.FirstOrDefault();
                
            }
        }

     

        public int SaveFile(TemplateFile model)
          
        {
            try
            {
                using (GestaoProjectosEntities lt = new GestaoProjectosEntities())
                {
                    lt.TemplateFiles.AddObject(model);
                    lt.SaveChanges();
                    return model.IDTemplate;

                }
            }
            catch (Exception ex)
            {
                return 0;
            }
        }

        public void DeleteFile()
        {
            try
            {
                using (GestaoProjectosEntities lt = new GestaoProjectosEntities())
                {
                    TemplateFile deptDelete = lt.TemplateFiles.FirstOrDefault();
                    lt.TemplateFiles.DeleteObject(deptDelete);
                    lt.SaveChanges();
                }
            }
            catch (Exception ex)
            {
            }
        }

        
    }
}
