Esempio n. 1
0
        /// <summary>
        /// Bind IDataReader to Entity
        /// </summary>
        public static ModulesEntity ReaderBind(IDataReader dataReader)
        {
            ModulesEntity model = new ModulesEntity();
            object        ojb;

            ojb = dataReader["ModuleID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ModuleID = (int)ojb;
                model.ID       = model.ModuleID;
            }
            model.ModuleTitle = dataReader["ModuleTitle"].ToString();
            model.ModulePath  = dataReader["ModulePath"].ToString();
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            ojb = dataReader["Orders"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Orders = (int)ojb;
            }
            ojb = dataReader["ParentID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ParentID = (int)ojb;
            }
            return(model);
        }
Esempio n. 2
0
        public ModulesEntity GetModule(int moduleID)
        {
            if (moduleID <= 0)
            {
                return(null);
            }
            ModulesEntity module = moduleRepository.Get(moduleID);

            return(module);
        }
Esempio n. 3
0
        public static ModulesEntity CreateModulesEntity(int createdByUserID, ISystemDateTime timeProvider)
        {
            ModulesEntity model = new ModulesEntity();

            model.CreatedBy  = createdByUserID;
            model.CreatedOn  = timeProvider.Now;
            model.ID         = 0;
            model.ModifiedBy = createdByUserID;
            model.ModifiedOn = timeProvider.Now;

            model.ModuleID    = 0;
            model.ModulePath  = string.Empty;
            model.ModuleTitle = string.Empty;
            model.Orders      = 0;
            model.ParentID    = 0;
            model.Status      = 0;

            return(model);
        }
Esempio n. 4
0
        /// <summary>
        /// Update Module
        /// </summary>
        /// <param name="module">Module to update</param>
        /// <param name="roleID">RoleID to update Cache</param>
        /// <returns></returns>
        public bool UpdateModule(ModulesEntity module, int roleID)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <ModulesEntity> validator = new UpdateModuleValidator();

            if (!validator.Validate(module))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
            }
            if (!moduleRepository.Update(module))
            {
                this.AddBrokenRuleMessage();
                return(false);
            }
            string key = string.Format(CACHE_ROLEMODULES, roleID);

            cache[key] = null;
            return(true);
        }
Esempio n. 5
0
        public int AddModule(ModulesEntity module)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <ModulesEntity> validator = new AddModuleValidator();

            if (!validator.Validate(module))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
            }
            int id = moduleRepository.Insert(module);

            if (id <= 0)
            {
                this.AddBrokenRuleMessage();
                return(0);
            }
            module.ID = id;

            return(id);
        }