コード例 #1
0
ファイル: BookService.cs プロジェクト: seanqiusd/BookWormzAPI
 //Update
 public int UpdateBookByISBN(string ISBN, BookUpdate newBook)
 {
     using (var ctx = new ApplicationDbContext())
     {
         Book book = ctx.Books.Find(ISBN);
         if (book == null)
         {
             return(2);
         }
         //Using null-coalescing operator ?? to check if information entered to update
         book.BookTitle       = newBook.BookTitle ?? book.BookTitle;
         book.AuthorFirstName = newBook.AuthorFirstName ?? book.AuthorFirstName;
         book.AuthorLastName  = newBook.AuthorLastName ?? book.AuthorLastName;
         book.GenreOfBook     = newBook.GenreOfBook ?? book.GenreOfBook;
         book.Description     = newBook.Description ?? book.Description;
         if (ctx.SaveChanges() == 1)
         {
             return(0);
         }
         return(1);
     }
 }
コード例 #2
0
        // Put --Update a book detail via ISBN
        //[HttpPut]
        /// <summary>
        /// Update Existing Book In Database
        /// </summary>
        /// <param name="ISBN"></param>
        /// <param name="newBook"></param>
        /// <returns></returns>
        public IHttpActionResult Put([FromUri] string ISBN, [FromBody] BookUpdate newBook)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var service = CreateBookService();

            switch (service.UpdateBookByISBN(ISBN, newBook))
            {
            case 0:
                return(Ok($"{newBook.BookTitle} has been updated"));

            case 1:
                return(InternalServerError());

            case 2:
                return(BadRequest("Book not found"));

            default:
                return(InternalServerError());
            }
        }
コード例 #3
0
        private void EnableUpdate()
        {
            BookUpdate parent = Util.TryFindParent <BookUpdate>(this);

            if (string.IsNullOrEmpty(txtTitle.Text) == false)
            {
                parent.cmdUpdate.IsEnabled    = true;
                parent.cmdUpdateWeb.IsEnabled = true;
            }
            else if (string.IsNullOrEmpty(txtBarcode.Text) == false)
            {
                parent.cmdUpdateWeb.IsEnabled = true;
                if (string.IsNullOrEmpty(txtTitle.Text) == true)
                {
                    parent.cmdUpdate.IsEnabled = false;
                }
            }
            else
            {
                parent.cmdUpdate.IsEnabled    = false;
                parent.cmdUpdateWeb.IsEnabled = false;
            }
        }
コード例 #4
0
        public int Update(BookUpdate book)
        {
            int rowAffected = 0;

            using (IDbConnection con = new SqlConnection(strConnectionString))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                DynamicParameters parameters = new DynamicParameters();
                parameters.Add("@Id", book.ID);
                parameters.Add("@Avatar", book.Avatar);
                parameters.Add("@Name", book.Name);
                parameters.Add("@Author", book.Author);
                parameters.Add("@Description", book.Description);
                parameters.Add("@Year", book.Year);
                parameters.Add("@Number", book.Number);
                parameters.Add("@CateloryID", book.CateloryID);
                rowAffected = con.Execute("Book_Update", parameters, commandType: CommandType.StoredProcedure);
            }
            return(rowAffected);
        }
コード例 #5
0
ファイル: BookUpdateDAL.cs プロジェクト: ZB347954263/RailExam
        public IList <BookUpdate> GetBookUpdateByChapterID(int chapterID, int bookID)
        {
            IList <BookUpdate> objList = new List <BookUpdate>();

            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_BOOK_UPDATE_Q";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddInParameter(dbCommand, "p_chapter_id", DbType.Int32, chapterID);
            db.AddInParameter(dbCommand, "p_book_id", DbType.Int32, bookID);

            using (IDataReader dataReader = db.ExecuteReader(dbCommand))
            {
                while (dataReader.Read())
                {
                    BookUpdate obj = CreateModelObject(dataReader);
                    objList.Add(obj);
                }
            }

            return(objList);
        }
コード例 #6
0
        public async Task <IActionResult> UpdateBook([FromBody] BookUpdate bookUpdate, [FromQuery] string IniBookStatus, [FromQuery] string LaterBookStatus)
        {
            //借閱人借閱狀態關係
            if ((bookUpdate.BookStatusId == "B" || bookUpdate.BookStatusId == "C") && (bookUpdate.BookKeeperId == "" || bookUpdate.BookKeeperId == null))
            {
                return(Ok("此借閱狀態,借閱人不能為空"));
            }
            else
            {
                //insert 借閱紀錄
                if ((IniBookStatus == "A" || IniBookStatus == "U") && (LaterBookStatus == "B" || LaterBookStatus == "C"))
                {
                    LendRecordInsert lendRecordInsert = new LendRecordInsert();
                    lendRecordInsert.BookKeeperId = bookUpdate.BookKeeperId;
                    lendRecordInsert.BookID       = Convert.ToInt32(bookUpdate.BookID);

                    await _bookservice.InsertLendRecord(lendRecordInsert);
                }
                //update 書本資料
                await _bookservice.UpdateBook(bookUpdate);

                return(Ok("編輯成功"));
            }
        }
コード例 #7
0
ファイル: BookUpdateDAL.cs プロジェクト: ZB347954263/RailExam
        public void AddBookUpdate(BookUpdate BookChapter)
        {
            Database db = DatabaseFactory.CreateDatabase();

            string    sqlCommand = "USP_BOOK_UPDATE_I";
            DbCommand dbCommand  = db.GetStoredProcCommand(sqlCommand);

            db.AddOutParameter(dbCommand, "p_book_update_id", DbType.Int32, 4);
            db.AddInParameter(dbCommand, "p_book_id", DbType.Int32, BookChapter.BookId);
            db.AddInParameter(dbCommand, "p_chapter_id", DbType.Int32, BookChapter.ChapterId);
            db.AddInParameter(dbCommand, "p_update_person", DbType.String, BookChapter.updatePerson);
            db.AddInParameter(dbCommand, "p_update_date", DbType.DateTime, BookChapter.updateDate);
            db.AddInParameter(dbCommand, "p_update_cause", DbType.String, BookChapter.updateCause);
            db.AddInParameter(dbCommand, "p_update_content", DbType.String, BookChapter.updateContent);
            db.AddInParameter(dbCommand, "p_update_object", DbType.String, BookChapter.UpdateObject);
            db.AddInParameter(dbCommand, "p_memo", DbType.String, BookChapter.Memo);
            db.AddInParameter(dbCommand, "p_book_name", DbType.String, BookChapter.BookNameBak);
            db.AddInParameter(dbCommand, "p_chapter_name", DbType.String, BookChapter.ChapterNameBak);

            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                db.ExecuteNonQuery(dbCommand, transaction);

                transaction.Commit();
            }
            catch
            {
                transaction.Rollback();
            }
            connection.Close();
        }
コード例 #8
0
 private bool IsValid(BookUpdate book)
 {
     return(!string.IsNullOrEmpty(book.ImageUrl) && !book.Title.EndsWith("Variant)"));
 }
コード例 #9
0
        private void UpdateItem(ThumbItem thumbItem)
        {
            try
            {
                if (thumbItem == null)
                {
                    return;
                }

                bool?saved = false;

                switch (thumbItem.EType)
                {
                case EntityType.Apps:
                    AppsUpdate objAppsDetails = new AppsUpdate();
                    objAppsDetails.ItemsId = thumbItem.Id;
                    saved = objAppsDetails.ShowDialog();
                    if (saved == true)
                    {
                        Apps apps = new AppServices().Get(thumbItem.Id) as Apps;
                        FileThumbItem(thumbItem, apps);
                    }
                    break;

                case EntityType.Artist:
                    Task.Factory.StartNew(() => Util.NotifyEvent("ArtistDetail:" + thumbItem.Name));
                    ArtistDetail artistDetails = new ArtistDetail(thumbItem.Name, thumbItem.EType);
                    saved = artistDetails.ShowDialog();
                    break;

                case EntityType.Books:
                    BookUpdate objBookDetails = new BookUpdate();
                    objBookDetails.ItemsId = thumbItem.Id;
                    saved = objBookDetails.ShowDialog();
                    if (saved == true)
                    {
                        Books books = new BookServices().Get(thumbItem.Id) as Books;
                        FileThumbItem(thumbItem, books);
                    }
                    break;

                case EntityType.Games:
                    GameUpdate objGameDetails = new GameUpdate();
                    objGameDetails.ItemsId = thumbItem.Id;
                    saved = objGameDetails.ShowDialog();
                    if (saved == true)
                    {
                        Gamez games = new GameServices().Get(thumbItem.Id) as Gamez;
                        FileThumbItem(thumbItem, games);
                    }
                    break;

                case EntityType.Movie:
                    MovieUpdate objMovieDetails = new MovieUpdate();
                    objMovieDetails.ItemsId = thumbItem.Id;
                    saved = objMovieDetails.ShowDialog();
                    if (saved == true)
                    {
                        Movie movie = new MovieServices().Get(thumbItem.Id) as Movie;
                        FileThumbItem(thumbItem, movie);
                    }
                    break;

                case EntityType.Music:
                    MusicUpdate objMusicDetails = new MusicUpdate();
                    objMusicDetails.ItemsId = thumbItem.Id;
                    saved = objMusicDetails.ShowDialog();
                    if (saved == true)
                    {
                        Music music = new MusicServices().Get(thumbItem.Id) as Music;
                        FileThumbItem(thumbItem, music);
                    }
                    break;

                case EntityType.Nds:
                    NdsUpdate objNdsDetails = new NdsUpdate();
                    objNdsDetails.ItemsId = thumbItem.Id;
                    saved = objNdsDetails.ShowDialog();
                    if (saved == true)
                    {
                        Nds nds = new NdsServices().Get(thumbItem.Id) as Nds;
                        FileThumbItem(thumbItem, nds);
                    }
                    break;

                case EntityType.Series:
                    Main main = Util.TryFindParent <Main>(this);
                    main.NewSeasonAdded = false;
                    SerieUpdate objSerieDetails = new SerieUpdate();
                    objSerieDetails.ItemsId = thumbItem.Id;
                    saved = objSerieDetails.ShowDialog();
                    main.NewSeasonAdded = objSerieDetails.NewSeasonAdded;

                    if (objSerieDetails.NewSeasonAdded == true)
                    {
                        saved = true;
                    }

                    if (saved == true)
                    {
                        SeriesSeason serie = new SerieServices().Get(thumbItem.Id) as SeriesSeason;
                        FileThumbItem(thumbItem, serie);
                    }
                    break;

                case EntityType.XXX:
                    XxxUpdate objXxxDetails = new XxxUpdate();
                    objXxxDetails.ItemsId = thumbItem.Id;
                    saved = objXxxDetails.ShowDialog();
                    if (saved == true)
                    {
                        XXX xxx = new XxxServices().Get(thumbItem.Id) as XXX;
                        FileThumbItem(thumbItem, xxx);
                    }
                    break;
                }

                _currentItem = thumbItem;

                if (saved == true)
                {
                    RoutedEventArgs args = new RoutedEventArgs(UpdateEvent);
                    RaiseEvent(args);
                    Cursor = null;
                    ShowVisibleItems(MainStack);
                }
            }
            catch (Exception ex)
            {
                CatchException(ex);
            }
        }
コード例 #10
0
        private void UpdateItem(ThumbItem thumbItem)
        {
            try
            {
                bool?saved = false;

                switch (thumbItem.EType)
                {
                case EntityType.Apps:
                    AppsUpdate objAppsDetails = new AppsUpdate();
                    objAppsDetails.ItemsId = thumbItem.Id;
                    saved = objAppsDetails.ShowDialog();
                    break;

                case EntityType.Books:
                    BookUpdate objBookDetails = new BookUpdate();
                    objBookDetails.ItemsId = thumbItem.Id;
                    saved = objBookDetails.ShowDialog();
                    break;

                case EntityType.Games:
                    GameUpdate objGameDetails = new GameUpdate();
                    objGameDetails.ItemsId = thumbItem.Id;
                    saved = objGameDetails.ShowDialog();
                    break;

                case EntityType.Movie:
                    MovieUpdate objMovieDetails = new MovieUpdate();
                    objMovieDetails.ItemsId = thumbItem.Id;
                    saved = objMovieDetails.ShowDialog();
                    break;

                case EntityType.Music:
                    MusicUpdate objMusicDetails = new MusicUpdate();
                    objMusicDetails.ItemsId = thumbItem.Id;
                    saved = objMusicDetails.ShowDialog();
                    break;

                case EntityType.Nds:
                    NdsUpdate objNdsDetails = new NdsUpdate();
                    objNdsDetails.ItemsId = thumbItem.Id;
                    saved = objNdsDetails.ShowDialog();
                    break;

                case EntityType.Series:
                    SerieUpdate objSerieDetails = new SerieUpdate();
                    objSerieDetails.ItemsId = thumbItem.Id;
                    saved = objSerieDetails.ShowDialog();
                    break;

                case EntityType.XXX:
                    XxxUpdate objXxxDetails = new XxxUpdate();
                    objXxxDetails.ItemsId = thumbItem.Id;
                    saved = objXxxDetails.ShowDialog();
                    break;
                }

                if (saved == true)
                {
                    RoutedEventArgs args = new RoutedEventArgs(SaveEventCf);
                    RaiseEvent(args);
                }
            }
            catch (Exception ex)
            {
                CatchException(ex);
            }
        }
コード例 #11
0
        public void UpdateLine(MinibookMessage message)
        {
            BookUpdate book = (BookUpdate)message.BookHeader;

            DeleteLineByIndex(book.OldPosition);
        }
コード例 #12
0
        //public List<BookSearch> ToModelList(DataTable dt)
        //{
        //	throw new NotImplementedException();
        //}

        public void UpdateBook(BookUpdate updatedata)
        {
            throw new NotImplementedException();
        }
コード例 #13
0
ファイル: BookUpdateBLL.cs プロジェクト: ZB347954263/RailExam
 public void UpdateBookUpdate(BookUpdate BookUpdate)
 {
     dal.UpdateBookUpdate(BookUpdate);
 }
コード例 #14
0
ファイル: BookUpdateBLL.cs プロジェクト: ZB347954263/RailExam
 public void AddBookUpdate(BookUpdate BookUpdate)
 {
     dal.AddBookUpdate(BookUpdate);
 }
コード例 #15
0
 public void Update([FromBody] BookUpdate bookUpdate) => bookBusiness.Update(bookUpdate);
コード例 #16
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            BookUpdateBLL BookUpdateBLL = new BookUpdateBLL();
            BookUpdate    BookUpdate    = new BookUpdate();

            string strUpdateObject = Request.QueryString.Get("Object");

            if (txtCause.Text == string.Empty)
            {
                SessionSet.PageMessage = "更改原因不能为空!";
                return;
            }

            if (txtContent.Text == string.Empty)
            {
                SessionSet.PageMessage = "更改内容不能为空!";
                return;
            }

            if (ViewState["AddFlag"].ToString() == "1")     //新增
            {
                BookBLL objBookBll = new BookBLL();
                BookUpdate.BookId        = int.Parse(ViewState["BookID"].ToString());
                BookUpdate.ChapterId     = int.Parse(ViewState["ChapterID"].ToString());
                BookUpdate.updatePerson  = lblPerson.Text;
                BookUpdate.updateDate    = DateTime.Parse(lblDate.Text);
                BookUpdate.updateCause   = txtCause.Text;
                BookUpdate.updateContent = txtContent.Text;
                BookUpdate.Memo          = txtMemo.Text;
                BookUpdate.BookNameBak   = objBookBll.GetBook(Convert.ToInt32(ViewState["BookID"].ToString())).bookName;
                if (ViewState["ChapterID"].ToString() != "0")
                {
                    BookChapterBLL objChapterBll = new BookChapterBLL();
                    BookUpdate.ChapterNameBak =
                        objChapterBll.GetBookChapter(Convert.ToInt32(ViewState["ChapterID"].ToString())).ChapterName;
                }
                if (strUpdateObject == "insertchapterinfo")
                {
                    BookUpdate.ChapterNameBak = Server.UrlDecode(Request.QueryString.Get("newchaptername"));
                    BookUpdate.UpdateObject   = PrjPub.BOOKUPDATEOBJECT_INSERTCHAPTERINFO;
                }
                else if (strUpdateObject == "updatechapterinfo")
                {
                    BookUpdate.UpdateObject = PrjPub.BOOKUPDATEOBJECT_UPDATECHAPTERINFO;
                }
                else if (strUpdateObject == "chaptercontent")
                {
                    BookUpdate.UpdateObject = PrjPub.BOOKUPDATEOBJECT_CHAPTERCONTENT;
                }
                else if (strUpdateObject == "delbook")
                {
                    BookUpdate.UpdateObject = PrjPub.BOOKUPDATEOBJECT_DELBOOK;
                }
                else if (strUpdateObject == "delchapter")
                {
                    BookUpdate.UpdateObject = PrjPub.BOOKUPDATEOBJECT_DELCHAPTER;
                }
                else
                {
                    BookUpdate.UpdateObject = lblChapterName.Text;
                }
                BookUpdateBLL.AddBookUpdate(BookUpdate);

                Response.Write("<script>top.returnValue='true';window.close();</script>");
            }
            else        //修改
            {
                BookUpdate.BookId        = int.Parse(ViewState["BookID"].ToString());
                BookUpdate.ChapterId     = int.Parse(ViewState["ChapterID"].ToString());
                BookUpdate.updatePerson  = lblPerson.Text;
                BookUpdate.updateDate    = DateTime.Parse(lblDate.Text);
                BookUpdate.updateCause   = txtCause.Text;
                BookUpdate.updateContent = txtContent.Text;
                BookUpdate.Memo          = txtMemo.Text;

                BookUpdate.bookUpdateId = int.Parse(Request.QueryString.Get("id"));
                BookUpdateBLL.UpdateBookUpdate(BookUpdate);

                if (PrjPub.IsWuhan())
                {
                    Response.Write("<script>window.opener.form1.RefreshGrid.value='true';window.opener.form1.submit();window.close();</script>");
                }
                else
                {
                    Response.Write("<script>top.returnValue='true';window.close();</script>");
                }
            }
        }
コード例 #17
0
 public ApiResponse Update(long id, BookUpdate bookUpdate)
 {
     this.bookApplication.UpdateFromAPI(id, bookUpdate);
     return(new ApiResponseData(HttpStatusCode.OK, null));
 }