/// <summary> /// 查询用户新增的图书分类是否已存在 /// </summary> /// <param name="name">分类名</param> /// <returns></returns> public BookCategoryEntity QueryBookCategoryByName(string name) { try { BookCategoryEntity category = dal.TEntity <BookCategoryEntity>() .AsQueryable() .Where(it => it.Name == name) .First(); return(category); } catch (Exception ex) { throw ex; } }
public IActionResult Create([FromBody] BookCategoryEntity model) { try { if (model != null) { var x = _book_category.Create(model); return(Json(x)); } else { return(Json(model)); } } catch (Exception ex) { return(StatusCode(409, $"{ex.Message}")); } }
public IActionResult Update(Guid id, [FromBody] BookCategoryEntity model) { try { if (id == null) { return(StatusCode(400, $"ID is not valid.")); } else { var res = _book_category.Update(id, model); return(Json(res)); } } catch (Exception ex) { _logger.LogCritical($"Exception while get list of items.", ex); return(StatusCode(500, $"Exception while get list of items. {ex.Message}")); } }