using ResourcesManager.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ResourcesManager.Repositories
{
    public class BaseRepository : IDisposable
    {
        protected ApplicationDbContext Context;
        public BaseRepository(ApplicationDbContext context)
        {
            Context = context;
        }

        public virtual void Save()
        {
            Context.SaveChanges();
        }

        #region IDisposable Support
        private bool disposed = false;

        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    Context.Dispose();
                }
            }
            disposed = true;
        }

        public void Dispose()
        {
            if (Context != null)
            {
                Context.Dispose();
            }
        }
        #endregion
    }
}