public AddWishListModel AddBookToWishList(int userId, ShowWishListModel showWishListModel) { try { DatabaseConnection databaseConnection = new DatabaseConnection(this.configuration); List <StoredProcedureParameterData> paramList = new List <StoredProcedureParameterData>(); paramList.Add(new StoredProcedureParameterData("@UserId", userId)); paramList.Add(new StoredProcedureParameterData("@BookId", showWishListModel.BookId)); paramList.Add(new StoredProcedureParameterData("@IsUsed", true)); paramList.Add(new StoredProcedureParameterData("@CreatedDate", DateTime.Now)); paramList.Add(new StoredProcedureParameterData("@ModifiedDate", DateTime.Now)); DataTable table = databaseConnection.StoredProcedureExecuteReader("BookAddToWishList", paramList); var wishListData = new AddWishListModel(); foreach (DataRow dataRow in table.Rows) { wishListData = new AddWishListModel(); wishListData.Id = (int)dataRow["Id"]; wishListData.UserId = Convert.ToInt32(dataRow["UserId"].ToString()); wishListData.BookId = Convert.ToInt32(dataRow["BookId"].ToString()); wishListData.IsUsed = Convert.ToBoolean(dataRow["IsUsed"].ToString()); wishListData.CreatedDate = Convert.ToDateTime(dataRow["CreatedDate"]); wishListData.ModifiedDate = Convert.ToDateTime(dataRow["ModifiedDate"]); } return(wishListData); } catch (Exception exception) { throw new Exception(exception.Message); } }
public AddWishListModel AddBookToWishList(int userId, ShowWishListModel showWishListModel) { try { var response = this.wishListRL.AddBookToWishList(userId, showWishListModel); return(response); } catch (Exception exception) { throw new Exception(exception.Message); } }
public IActionResult AddWishList(int userId, ShowWishListModel showWishListModel) { try { var claim = Convert.ToInt32(HttpContext.User.Claims.FirstOrDefault(c => c.Type == "Id").Value); var data = this.wishListBL.AddBookToWishList(claim, showWishListModel); if (data != null) { return(this.Ok(new { status = "True", message = "Book Added To WishList Successfully", data })); } else { return(this.BadRequest(new { status = "False", message = "Failed To Add WishList" })); } } catch (Exception exception) { return(BadRequest(new { message = exception.Message })); } }