Ejemplo n.º 1
0
        public static string Save(RoleElementAccessModel model)
        {
            if (string.IsNullOrEmpty(model.RoleID) || string.IsNullOrEmpty(model.ElementID))
            {
                throw new Exception("RoleID and ElementID are both required.");
            }

            string key = KEY_PREFIX + model.RoleID + "-" + model.ElementID;

            //check if this is a new entry
            if (!client.KeyExists(key))
            {
                model.Created = DateTimeOffset.Now;
            }

            model.LastModified = DateTimeOffset.Now;

            if (client.StoreJson(Enyim.Caching.Memcached.StoreMode.Set, key, model))
            {
                return(key);
            }

            Exceptions.CouchbaseSaveException ex =
                new Exceptions.CouchbaseSaveException(model.Type, model);

            throw (ex);
        }
Ejemplo n.º 2
0
        public static string Save(RoleElementAccessModel model)
        {
            if (string.IsNullOrEmpty(model.RoleID) || string.IsNullOrEmpty(model.ElementID))
            {
                throw new Exception("RoleID and ElementID are both required.");
            }

            string key = KEY_PREFIX + model.RoleID + "-" + model.ElementID;

            //check if this is a new entry
            if (!client.KeyExists(key))
            {
                model.Created = DateTimeOffset.Now;
            }

            model.LastModified = DateTimeOffset.Now;

            if (client.StoreJson(Enyim.Caching.Memcached.StoreMode.Set, key, model))
            {
                return key;
            }

            Exceptions.CouchbaseSaveException ex =
                new Exceptions.CouchbaseSaveException(model.Type, model);

            throw (ex);
        }
Ejemplo n.º 3
0
        public static string Save(RoleModel model)
        {
            if (string.IsNullOrEmpty(model.RoleID))
            {
                model.RoleID  = GenerateDbKey(KEY_PREFIX);
                model.Created = DateTimeOffset.Now;
            }

            string key = KEY_PREFIX + model.RoleID;

            model.LastModified = DateTimeOffset.Now;

            if (client.StoreJson(Enyim.Caching.Memcached.StoreMode.Set, key, model))
            {
                return(key);
            }

            Exceptions.CouchbaseSaveException ex =
                new Exceptions.CouchbaseSaveException(model.Type, model);

            throw (ex);
        }
Ejemplo n.º 4
0
        public static string Save(RoleModel model)
        {
            if (string.IsNullOrEmpty(model.RoleID))
            {
                model.RoleID = GenerateDbKey(KEY_PREFIX);
                model.Created = DateTimeOffset.Now;
            }

            string key = KEY_PREFIX + model.RoleID;

            model.LastModified = DateTimeOffset.Now;

            if (client.StoreJson(Enyim.Caching.Memcached.StoreMode.Set, key, model))
            {
                return key;
            }

            Exceptions.CouchbaseSaveException ex =
                new Exceptions.CouchbaseSaveException(model.Type, model);

            throw (ex);
        }