public async Task <(List <ValidationResult> Result, CheckoutDto Checkout)> CheckoutBook(CheckoutDto vm)
        {
            results.Clear();
            try
            {
                var user = await _userServ.GetUser(vm.UserId);

                if (user == null)
                {
                    results.Add(new ValidationResult("Invalid User ID."));
                    return(results, null);
                }
                //calculate the elapsed date
                int days        = 10;
                var ElapsedDate = DateTime.Now.AddBusinessDays(days);

                var checkout = new Checkout();
                checkout.Id           = Guid.NewGuid();
                checkout.UserId       = vm.UserId;
                checkout.CheckoutDate = DateTime.Now.GetDateUtcNow();
                checkout.ReturnDate   = ElapsedDate;
                checkout.CreatedOn    = DateTime.Now.GetDateUtcNow();
                checkout.ModifiedOn   = DateTime.Now.GetDateUtcNow();

                this.UnitOfWork.BeginTransaction();

                if (vm.SelectedBooks?.Count > 0)
                {
                    foreach (var userStore in vm.SelectedBooks)
                    {
                        //get details of selected book
                        var checkBook = _bookServ.FirstOrDefault(s => s.Id == userStore.Book_Id);
                        if (checkBook == null)
                        {
                            results.Add(new ValidationResult("Selected Book's are Wrong"));
                            return(results, null);
                        }
                        checkBook.ISBN = checkBook.ISBN;

                        var bookCheckout = new BookCheckout()
                        {
                            Book       = checkBook,
                            CheckoutId = checkout.Id,
                            CreatedOn  = DateTime.Now.GetDateUtcNow(),
                            ModifiedOn = DateTime.Now.GetDateUtcNow()
                        };

                        checkout.BookCheckouts.Add(bookCheckout);
                    }
                }
                await this.AddAsync(checkout);

                await this.UnitOfWork.CommitAsync();
            }
            catch (Exception ex)
            {
                results.Add(new ValidationResult($"Unable to Checkout! \n {ex.Message}"));
            }
            return(results, vm);
        }
        public async Task <IActionResult> UpdateUser([FromBody] UserForUpdateDto payload, Guid id, Guid UserId)
        {
            ApiResponse <UserForUpdateDto> response = new ApiResponse <UserForUpdateDto>();

            try
            {
                if (!response.Errors.Any())
                {
                    var userFromRepo = await _userSrv.GetUser(id);

                    if (userFromRepo == null)
                    {
                        return(BadRequest(new { errorList = "Invalid User Id" }));
                    }
                    var currentUserId = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                    if (currentUserId != userFromRepo.Email)
                    {
                        return(BadRequest(new { errorList = "UnAuthorized" }));
                    }
                    (List <ValidationResult> Result, UserForUpdateDto User)errorResult = await _userSrv.UpdateUser(payload, UserId);

                    if (errorResult.Result.Any())
                    {
                        return(BadRequest(new { errorList = $"{errorResult.Result.FirstOrDefault().ErrorMessage}" }));
                    }
                    else
                    {
                        response.Code        = ApiResponseCodes.OK;
                        response.Description = $"User Updated Successfully.";
                    }
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(Ok(response));
        }