Пример #1
0
        /// <summary>
        /// Bind IDataReader to Entity
        /// </summary>
        public static FilesEntity ReaderBind(IDataReader dataReader)
        {
            FilesEntity model = new FilesEntity();
            object      ojb;

            ojb = dataReader["FileID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FileID = (int)ojb;
            }
            ojb = dataReader["SourceID"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SourceID = (int)ojb;
            }
            ojb = dataReader["SourceType"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.SourceType = (int)ojb;
            }
            model.FileTitle   = dataReader["FileTitle"].ToString();
            model.ContentType = dataReader["ContentType"].ToString();
            ojb = dataReader["FileSize"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.FileSize = (int)ojb;
            }
            model.FilePath  = dataReader["FilePath"].ToString();
            model.ThumbPath = dataReader["ThumbPath"].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["IsDelete"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsDelete = (bool)ojb;
            }
            ojb = dataReader["IsPublic"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.IsPublic = (bool)ojb;
            }
            return(model);
        }
Пример #2
0
        public int AddFile(FilesEntity entity)
        {
            this.ClearBrokenRuleMessages();

            BaseValidator <FilesEntity> validator = new FilesValidator();

            if (!validator.Validate(entity))
            {
                this.AddBrokenRuleMessages(validator.BrokenRuleMessages);
                return(0);
            }

            int id = fileRepo.Insert(entity);

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

            return(id);
        }