public async Task <ActionResult> AddToBag(int bookId) { RequestResponse <int> response = new RequestResponse <int>(); try { var member = await _unitOfWork.Members.GetMemberByUsernameWithBooksAsync(User.GetUsername()); var result = _memberService.AddToBag(member, bookId); if (result == 2) { response.Message = Utility.ResponseHelper.BookAlreadyInBag; response.Status = Utility.ResponseHelper.FailureCode; } else { response.Message = Utility.ResponseHelper.BookAddedToBag; response.Status = Utility.ResponseHelper.SuccessCode; } if (_unitOfWork.HasChanges()) { await _unitOfWork.CompleteAsync(); } return(Ok(response)); } catch (Exception ex) { response.Message = ex.Message; response.Status = Utility.ResponseHelper.FailureCode; return(Ok(response)); } }