コード例 #1
0
        public BookVo Update(BookVo book)
        {
            var entityBook = this.converter.Parse(book);

            entityBook = this.repository.Update(entityBook);
            return(this.converter.Parse(entityBook));
        }
コード例 #2
0
ファイル: SimpleData.cs プロジェクト: xknife-erian/nknife
        /// <summary>
        /// 从Excel文件中获取所有书籍
        /// </summary>
        private async Task <IEnumerable <BookVo> > GetBooksAsync()
        {
            var       list     = new List <BookVo>();
            var       bs       = Resources.图书目录资料;
            IWorkbook workbook = new XSSFWorkbook(new MemoryStream(bs));
            ISheet    sheet    = workbook.GetSheetAt(0); //获取第一个工作表

            for (int i = 1; i < sheet.LastRowNum; i++)   //对工作表每一行
            {
                var row = sheet.GetRow(i);
                if (row != null)
                {
                    var book = new BookVo
                    {
                        Id    = row.GetCell(0).ToString(),
                        Name  = row.GetCell(1).ToString(),
                        ISBN  = row.GetCell(2).ToString(),
                        Price = (float)Convert.ToDouble(row.GetCell(3).NumericCellValue)
                    };
                    var pubName = row.GetCell(4).ToString().Trim();
                    book.Publisher = new PublisherVo()
                    {
                        Id   = Guid.NewGuid().ToString(),
                        Name = pubName
                    };
                    list.Add(book);
                }
            }
            workbook.Close();
            return(list);
        }
コード例 #3
0
 public IActionResult Put([FromBody] BookVo book)
 {
     if (book == null)
     {
         NotFound();
     }
     return(new ObjectResult(this.bookBusiness.Update(book)));
 }
コード例 #4
0
        public IActionResult Post([FromBody] BookVo book)
        {
            if (book == null)
            {
                return(BadRequest());
            }

            return(new ObjectResult(this.bookBusiness.Create(book)));
        }
コード例 #5
0
        public async Task BuyBook(PersonVo person, BookVo book)
        {
            var buyingRecord = new BuyingRecord();

            buyingRecord.Id           = Guid.NewGuid().ToString();
            buyingRecord.TradingPrice = (float)(book.Price * 0.8);
            buyingRecord.CurrentOwner = person.Id;
            buyingRecord.TradingTime  = DateTime.Now.AddMinutes(-_Random.Next(100, 10000));
            buyingRecord.Book         = book.Id;
            await _buyingRecordWrite.InsertAsync(buyingRecord);
        }
コード例 #6
0
        public string AppReturnBook(Stream s)
        {
            string ret = "0";

            try
            {
                var    sr           = new StreamReader(s);
                string text         = sr.ReadToEnd();
                BookVo data         = JsonConvert.DeserializeObject <BookVo>(text);
                string ConsultID    = data.ConsultID;
                string ReturnReason = HttpUtility.UrlDecode(data.ReturnReason);
                string sql          = string.Format("update Consultation set ConsultStatusID=101 , ReturnReason='" + ReturnReason + "' where ConsultID={0}", ConsultID);
                op.ExecuteNonQuery(sql, CommandType.Text, null);

                ret = "1";
            }
            catch
            {
            }


            return(ret);
        }