Beispiel #1
0
 public Book(
     string name,
     ISet <Author> authors,
     PublishingHouse publishingHouse,
     Language language,
     BookType bookType,
     BookCoverType bookCoverType,
     int pagesCount,
     string description,
     string isbn,
     int issueYear,
     decimal price,
     DateTime created,
     ProductCategory productCategory,
     bool isActive) : base(name, price, productCategory, created, isActive)
 {
     Authors         = authors;
     ISBN            = isbn;
     IssueYear       = issueYear;
     Language        = language;
     PublishingHouse = publishingHouse;
     PagesCount      = pagesCount;
     Description     = description;
     BookType        = bookType;
     BookCoverType   = bookCoverType;
 }
Beispiel #2
0
 /// <summary>
 /// 从读取器向完整实例对象赋值
 /// </summary>/// <param name="reader">数据读取器</param>
 /// <returns>返回本对象实例</returns>
 public ProBook BuildSampleEntity(IDataReader reader)
 {
     this.BookId       = DBConvert.ToInt32(reader["book_id"]);
     this.BookName     = DBConvert.ToString(reader["book_name"]);
     this.BookSize     = (BookSize)DBConvert.ToInt32(reader["book_size"]);
     this.BookType     = DBConvert.ToInt32(reader["book_type"]);
     this.CreateTime   = DBConvert.ToDateTime(reader["create_time"]);
     this.AdUserId     = DBConvert.ToInt32(reader["ad_user_id"]);
     this.Introduction = DBConvert.ToString(reader["introduction"]);
     this.State        = (StateType)DBConvert.ToInt32(reader["state"]);
     this.EditeTime    = DBConvert.ToDateTime(reader["edite_time"]);
     this.BookCover    = (BookCoverType)DBConvert.ToInt32(reader["book_cover"]);
     return(this);
 }
Beispiel #3
0
        public AdvancedResult <int> AddBook(string bookname, BookSize booksize, BookCoverType bookcover, int booktype, string introduction, string token)
        {
            AdvancedResult <int> result = new AdvancedResult <int>();

            try
            {
                if (string.IsNullOrEmpty(bookname))
                {
                    result.Error = AppError.ERROR_BOOK_NOT_NULL;
                    return(result);
                }
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));

                    //int userid = 5;
                    ProBook book = new ProBook();

                    book.BookName     = bookname.Trim();
                    book.BookSize     = booksize;
                    book.BookType     = booktype;
                    book.AdUserId     = userid;
                    book.BookCover    = bookcover;
                    book.Introduction = string.IsNullOrEmpty(introduction) ? string.Empty : introduction.Trim();

                    result.Data = ProBookAccessor.Instance.Insert(book);

                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
        public AdvancedResult<int> AddBook(string bookname, BookSize booksize,BookCoverType bookcover, int booktype, string introduction, string token)
        {
            AdvancedResult<int> result = new AdvancedResult<int>();
            try
            {
                if (string.IsNullOrEmpty(bookname))
                {
                    result.Error = AppError.ERROR_BOOK_NOT_NULL;
                    return result;
                }
                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    int userid = Convert.ToInt32(CacheManagerFactory.GetMemoryManager().Get(token));

                //int userid = 5;
                    ProBook book = new ProBook();

                    book.BookName = bookname.Trim();
                    book.BookSize = booksize;
                    book.BookType = booktype;
                    book.AdUserId = userid;
                    book.BookCover = bookcover;
                    book.Introduction = string.IsNullOrEmpty(introduction) ? string.Empty : introduction.Trim();

                    result.Data = ProBookAccessor.Instance.Insert(book);

                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return result;
        }
Beispiel #5
0
        public RespResult EditBook(int bookid, string bookname, BookSize booksize, BookCoverType bookcover, int booktype, string introduction, string token)
        {
            RespResult result = new RespResult();

            try
            {
                if (string.IsNullOrEmpty(bookname))
                {
                    result.Error = AppError.ERROR_BOOK_NOT_NULL;
                    return(result);
                }

                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {
                    ProBook book = new ProBook();
                    book.BookId       = bookid;
                    book.BookName     = bookname.Trim();
                    book.BookSize     = booksize;
                    book.BookType     = booktype;
                    book.BookCover    = bookcover;
                    book.Introduction = string.IsNullOrEmpty(introduction) ? string.Empty : introduction.Trim();
                    book.State        = StateType.Active;

                    ProBookAccessor.Instance.Update(book);

                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error     = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return(result);
        }
        public RespResult EditBook(int bookid, string bookname, BookSize booksize, BookCoverType bookcover, int booktype, string introduction, string token)
        {
            RespResult result = new RespResult();
            try
            {
                if (string.IsNullOrEmpty(bookname))
                {
                    result.Error = AppError.ERROR_BOOK_NOT_NULL;
                    return result;
                }

                if (!CacheManagerFactory.GetMemoryManager().Contains(token))
                {
                    result.Error = AppError.ERROR_PERSON_NOT_LOGIN;
                }
                else
                {

                    ProBook book = new ProBook();
                    book.BookId = bookid;
                    book.BookName = bookname.Trim();
                    book.BookSize = booksize;
                    book.BookType = booktype;
                    book.BookCover = bookcover;
                    book.Introduction = string.IsNullOrEmpty(introduction) ? string.Empty : introduction.Trim();
                    book.State = StateType.Active;

                    ProBookAccessor.Instance.Update(book);

                    result.Error = AppError.ERROR_SUCCESS;
                }
            }
            catch (Exception e)
            {
                result.Error = AppError.ERROR_FAILED;
                result.ExMessage = e.ToString();
            }
            return result;
        }