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

            ojb = dataReader["GID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.GID = (int)ojb;
            }
            model.Title = dataReader["Title"].ToString();
            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;
            }
            ojb = dataReader["IsOnlyShowTody"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsOnlyShowTody = (bool)ojb;
            }
            ojb = dataReader["IsDelete"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsDelete = (bool)ojb;
            }
            return(model);
        }
Ejemplo n.º 2
0
        public int AddCateGory(CateGoryEntity entity)
        {
            this.ClearBrokenRuleMessages();
            BaseValidator <CateGoryEntity> validator = new AddCateGoryValidator();

            if (!validator.Validate(entity))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }
            if (!CheckCategory(entity.Title
                               .TrimEnd(" ".ToCharArray())
                               .TrimStart(" ".ToCharArray()),
                               entity.CreatedBy))
            {
                this.AddBrokenRuleMessage("Error",
                                          string.Format("You have create a category with the title [{0}].",
                                                        entity.Title));
                return(0);
            }
            int id = cgRepo.Insert(entity);

            if (id <= 0)
            {
                this.AddBrokenRuleMessage();
                return(0);
            }
            ClearCache();
            entity.ID = id;
            return(id);
        }
Ejemplo n.º 3
0
        public CateGoryEntity GetCateGory(int id)
        {
            this.ClearBrokenRuleMessages();
            if (id <= 0)
            {
                return(null);
            }

            CateGoryEntity entity = cgRepo.Get(id);

            return(entity);
        }