public T Create <T>(T entity) where T : class
        {
            PropertyUtilities.TrySetProperty(entity, "Created", DateTime.Now);
            PropertyUtilities.TrySetProperty(entity, "CreatedBy", 1);
            PropertyUtilities.TrySetProperty(entity, "Modified", DateTime.Now);
            PropertyUtilities.TrySetProperty(entity, "ModifiedBy", 1);

            _context.Set <T>().Add(entity);
            _context.SaveChanges();

            return(entity);
        }
        public T Update <T>(T entity) where T : class
        {
            var fieldsToIgnore = new string[] { "Id", "Created", "CreatedBy", "Modified", "ModifiedBy" };
            int id             = (int)PropertyUtilities.TryGetProperty(entity, "Id");
            T   found          = FindById <T>(id);

            foreach (PropertyInfo property in typeof(T).GetProperties())
            {
                if (!fieldsToIgnore.Contains(property.Name))
                {
                    PropertyUtilities.TrySetProperty(found, property.Name, property.GetValue(entity));
                }
            }

            PropertyUtilities.TrySetProperty(found, "Modified", DateTime.Now);
            PropertyUtilities.TrySetProperty(found, "ModifiedBy", 1);

            _context.SaveChanges();

            return(found);
        }