public async Task <UserResponse> VerifyEmailtoken(string token) { try { var user = await GetUserInfoFromToken(token); if (user == null) { throw new ArgumentNullException(nameof(token)); } return(_mapper.Map <User, UserResponse>(user , opts => opts.BeforeMap((x, y) => { x.TransformImageUrls(_imageStorageService, _device); x.Images = _imageStorageService.TransformImageUrls(x.Images, ImageType.UserProfile, _device); x.HeroImageUrl = _imageStorageService.GetCloudinaryImageUrl(ImageType.UserHeroImage, x.HeroImageUrl, _device); }))); } catch (Exception e) { _logger.LogError(e.Message, e); _logger.LogInformation("Can't verify token: {tokenString}", token); throw new ValidationException("Token is incorrect"); } }
public async Task <int> ConfirmBooking([FromBody] BookingRequest request) { try { //if (id < 100000 || id > 1000000) throw new ValidationException(nameof(id)); if (request == null || !request.Participants.Any()) { throw new ArgumentNullException(nameof(request)); } //var jsonBookingRequest = JsonConvert.SerializeObject(request); var bookingId = await _bookingService.AddBooking(request); var listingDetail = _listingService.GetListingViewById(request.ListingId).Result; var bookingParticipants = request.Participants.Select(item => new BookingParticipant { Fullname = $"{item.FirstName} {item.LastName}", DateOfBirth = item.Birthday.ToString(), Email = item.Email, Phone = item.Phone, EmergencyContact = item.EmergencyContact }).ToList(); var listingUrl = $"{Request.Headers["Access-Control-Allow-Origin"]}/listing/{StringHelper.SeorizeListingName(listingDetail.Header, listingDetail.Id)}"; var bookingUrl = $"{Request.Headers["Access-Control-Allow-Origin"]}/booking/{StringHelper.SeorizeListingName(listingDetail.Header, bookingId)}"; var manageBookingUrl = $"{Request.Headers["Access-Control-Allow-Origin"]}/booking/manage/{StringHelper.SeorizeListingName(listingDetail.Header, listingDetail.Id)}";; var bookingEmailViewModel = new BookingEmailViewModel { ListingId = listingDetail.Id, ListingUrl = listingUrl, BookingUrl = bookingUrl, ManageBookingUrl = manageBookingUrl, MainImageUrl = _imageStorageService.GetCloudinaryImageUrl(ImageType.Listing, listingDetail.ImageUrls.Split(";").FirstOrDefault()), ListingHeader = listingDetail.Header, ListingDescription = listingDetail.Description, BookingDate = request.BookingDate.ToString("dddd dd-MMM-yyyy", CultureInfo.DefaultThreadCurrentUICulture), BookingTime = request.Time.ToString(@"hh\:mm", CultureInfo.DefaultThreadCurrentUICulture), BookingParticipants = bookingParticipants }; return(await _emailService.SendBookingConfirmEmail(bookingEmailViewModel, listingDetail.OwnerEmail, listingDetail.OwnerEmail)); //return ; } catch (Exception e) { _logger.LogError(e.Message, e); throw; } }