Example #1
0
		public async Task RegisterAsync(Attendee attendee)
		{
			var data = AppFactory.Mapper.Value.Map<Data.Entity.Table.Attendee>(attendee);

			var token = new QuickAuthToken
			{
				Email = attendee.EMail,
				Token = Guid.NewGuid().ToString("N")
			};

			var email = new ConfirmRegistrationMessage
			{
				Email = attendee.EMail,
				FullName = attendee.FullName,
				Token = token.Token
			};

			await Task.WhenAll(
				DataFactory.AttendeeService.Value.InsertAsync(data),
				AppFactory.QuickAuthTokenService.Value.AddQuickAuthTokenAsync(token),
				NotificationFactory.AttendeeNotificationService.Value.SendRegistrationConfirmationEmailAsync(email)
			);
		}
		public async Task AddQuickAuthTokenAsync(QuickAuthToken token)
		{
			var authToken = AppFactory.Mapper.Value.Map<Data.Entity.Table.QuickAuthToken>(token);
			await DataFactory.QuickAuthTokenService.Value.InsertAsync(authToken);
		}
		public async Task<ActionResult> RestorePassword(LoginModel model)
		{
			var user = await AppFactory.AttendeeService.Value.GetAttendeeByEmailAsync(model.Email);

			if (user != null)
			{
				var token = new QuickAuthToken
				{
					Email = user.EMail,
					Token = Guid.NewGuid().ToString("N")
				};

				var notification = new RestorePasswordMessage
				{
					Email = user.EMail,
					FullName = user.FullName,
					Token = token.Token
				};

				await Task.WhenAll(
					AppFactory.QuickAuthTokenService.Value.AddQuickAuthTokenAsync(token),
					NotificationFactory.AttendeeNotificationService.Value.SendRestorePasswordEmailAsync(notification)
				);
			}

			return View();
		}