public BookCase AddBookCase(BookCase bookCase) { _repositoryWrapper.BookCase.AddBookCase(bookCase); //_logger.WriteInfo($"Added user with id: {user.Id}."); return(bookCase); }
public static List <BookCase> GetBookCaseList() { List <BookCase> list = new List <BookCase>(); BookCase bc = null; DataTable dt = DBHelper.GetDataTable(@"SELECT [bookcaseID] ,[bookcaseName] FROM [dbo].[tb_bookcase]"); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { try { bc = new BookCase(); bc.bookcaseID = dr["bookcaseID"] == DBNull.Value ? -1 : (int)dr["bookcaseID"]; bc.bookcaseName = dr["bookcaseName"] == DBNull.Value ? string.Empty : dr["bookcaseName"].ToString().Trim(); } catch (Exception) { throw; } finally { list.Add(bc); } } } return(list); }
public BookCase UpdateBookCase(BookCase existing, BookCase bookCase) { _repositoryWrapper.BookCase.UpdateBookCase(existing, bookCase); // _logger.WriteInfo($"Updated user with id: {user.Id}."); return(bookCase); }
/// <summary> /// 删除图书位置对象 /// </summary> /// <param name="bookType">位置对象</param> /// <returns>修改结果 bool</returns> public static bool DeletebookCase(BookCase bookCase) { StringBuilder sql = new StringBuilder(); Dictionary <string, string> values = new Dictionary <string, string>(); sql.Append(@"DELETE FROM [dbo].[tb_bookcase] WHERE [bookcaseID]=@id"); values.Add("@id", bookCase.bookcaseID.ToString()); return(BookInfoService.UpBookInfo(sql.ToString(), values)); }
public ActionResult Post([FromBody] BookCase newItem) { if (newItem is null) { return(BadRequest()); } var item = _bookCaseService.AddBookCase(newItem); return(Ok(item)); }
/// <summary> /// 增加图书位置对象 /// </summary> /// <param name="bookType">位置对象</param> /// <returns>修改结果 bool</returns> public static bool AddbookCase(BookCase bookCase) { StringBuilder sql = new StringBuilder(); Dictionary <string, string> values = new Dictionary <string, string>(); sql.Append(@"INSERT INTO [dbo].[tb_bookcase] ([bookcaseName]) VALUES (@name)"); values.Add("@name", bookCase.bookcaseName); return(BookInfoService.UpBookInfo(sql.ToString(), values)); }
//图书的位置对象操作 /// <summary> /// 修改图书位置对象 /// </summary> /// <param name="bookType">修改位置对象</param> /// <returns>修改结果 bool</returns> public static bool UpbookCase(BookCase bookCase) { StringBuilder sql = new StringBuilder(); Dictionary <string, string> values = new Dictionary <string, string>(); sql.Append(@"UPDATE [dbo].[tb_bookcase] SET [bookcaseName] =@name WHERE [bookcaseID]=@id"); values.Add("@name", bookCase.bookcaseName); values.Add("@id", bookCase.bookcaseID.ToString()); return(BookInfoService.UpBookInfo(sql.ToString(), values)); }
public BookCase GetById(int caseId) { BookCase bc = new BookCase(); try { DataRow dr = DBHelper.GetDataRow("SELECT [bookcaseID] ,[bookcaseName] FROM [dbo].[tb_bookcase] where [bookcaseID]=@id;", new SqlParameter("@id", caseId)); bc.bookcaseID = dr["bookcaseID"] == DBNull.Value ? -1 : (int)dr["bookcaseID"]; bc.bookcaseName = dr["bookcaseName"] == DBNull.Value ? string.Empty : dr["bookcaseName"].ToString().Trim(); } catch (Exception) { bc.bookcaseID = -1; bc.bookcaseName = ""; } return(bc); }
public static bool AddBookCase(string jsonStr) { BookCase bc = null; try { JavaScriptSerializer js = new JavaScriptSerializer(); bc = js.Deserialize <BookCase>(jsonStr); return(bc != null?BookCatologManger.AddbookCase(bc) : false); //return bc; } catch (Exception) { return(false); // return bc; } }
public ActionResult Put([FromBody] BookCase changedItem) { if (changedItem is null) { return(BadRequest()); } var existingItem = _bookCaseService.AsQueryable() .Where(x => x.Id == changedItem.Id) .FirstOrDefault(); if (existingItem is null) { return(NotFound()); } var item = _bookCaseService.UpdateBookCase(existingItem, changedItem); return(Ok(item)); }
public async Task <int> Update(BookCase bookCase) { var result = await _httpService.Put <BookCase>($"/bookcases/{bookCase.Id}", bookCase); return(result.Id); }
public async Task <int> Create(BookCase bookCase) { var result = await _httpService.Post <BookCase>("/bookcases", bookCase); return(result.Id); }
public void RemoveBookCase(BookCase bookCase) { _repositoryWrapper.BookCase.RemoveBookCase(bookCase); // _logger.WriteInfo($"Removed user with id: {user.Id}."); }