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

            ojb = dataReader["RoleID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.RoleID = (int)ojb;
                model.ID     = model.RoleID;
            }
            model.RoleName    = dataReader["RoleName"].ToString();
            model.Description = dataReader["Description"].ToString();
            ojb = dataReader["Status"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.Status = (int)ojb;
            }
            ojb = dataReader["CreatedOn"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreatedOn = (DateTime)ojb;
            }
            ojb = dataReader["CreatedBy"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.CreatedBy = (int)ojb;
            }
            return(model);
        }
Ejemplo n.º 2
0
        public RolesEntity GetRole(int roleID)
        {
            if (roleID <= 0)
            {
                return(null);
            }
            RolesEntity role = roleRepository.Get(roleID);

            if (role == null)
            {
                return(null);
            }
            return(role);
        }
Ejemplo n.º 3
0
        public static RolesEntity CreateRolesEntity(int createdByUserID, ISystemDateTime timeProvider)
        {
            RolesEntity model = new RolesEntity();

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

            model.RoleID   = 0;
            model.RoleName = string.Empty;
            model.Status   = 0;

            return(model);
        }
Ejemplo n.º 4
0
        public bool UpdateRole(RolesEntity role)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <RolesEntity> validator = new UpdateRoleValidator();

            if (!validator.Validate(role))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(false);
            }
            if (!roleRepository.Update(role))
            {
                this.AddBrokenRuleMessage();
                return(false);
            }
            return(true);
        }
Ejemplo n.º 5
0
        public int AddRole(RolesEntity role)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <RolesEntity> validator = new AddRoleValidator();

            if (!validator.Validate(role))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }
            int id = roleRepository.Insert(role);

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