Пример #1
0
        /// <summary>
		/// Adds a User
		/// </summary>
		public void AddUser(User user)
		{
			if (user == null)
			{
				throw new ArgumentNullException("user");
			}

			user.DateCreated = DateTime.Now;
			this.Repository.Add(user);
		}
		/// <summary>
		/// ctor the Mighty
		/// </summary>
		public SendToShopOrderPartnerNotificationMessage(Partner partner, PartnerSendToShopSettings partnerSendToShopSettings, 
			SendToShopOrder sendToShopOrder, User user, IStringCryptoService stringCryptoService, IWebSettings webSettings,
			IRecipeDataService recipeDataService)
		{
			this.Partner = partner;
			this.SendToShopOrder = sendToShopOrder;
			this.User = user;
			this.StringCryptoService = stringCryptoService;
			this.WebSettings = webSettings;

			this.Ingredients = recipeDataService.GetAllPublicIngredients();

			// Message Setup
			this.FormatAsHtml = true;
			this.Subject = "Brewgr.com - Send-To-Shop Order #:" + sendToShopOrder.SendToShopOrderId;
			this.SenderAddress = webSettings.SenderAddress;
			this.SenderDisplayName = webSettings.SenderDisplayName;
			this.ToRecipients.Add(partnerSendToShopSettings.DeliveryEmailAddress);
		}
Пример #3
0
		/// <summary>
		/// Unsubscribes a user from a notification Type
		/// </summary>
		public void UnsubscribeUserFromNotificationType(User user, NotificationType notificationType)
		{
			if (user == null)
			{
				throw new ArgumentNullException("user");
			}

			var userNotificationType = user.UserNotificationTypes.FirstOrDefault(x => x.NotificationTypeId == (int) notificationType);

			if (userNotificationType == null)
			{
				return;
			}

			this.Repository.Delete(userNotificationType);
		}
Пример #4
0
		/// <summary>
		/// Subscribes a user to a notification type
		/// </summary>
		public void SubscribeUserToNotificationType(User user, NotificationType notificationType)
		{
			if (user == null)
			{
				throw new ArgumentNullException("user");
			}

			var userNotificationType = user.UserNotificationTypes.FirstOrDefault(x => x.NotificationTypeId == (int)notificationType);

			if (userNotificationType != null)
			{
				return;
			}

			userNotificationType = new UserNotificationType
			{
				NotificationTypeId = (int)notificationType,
				DateCreated = DateTime.Now
			};

			user.UserNotificationTypes.Add(userNotificationType);
		}
Пример #5
0
		/// <summary>
		/// Subscribes a user to default user notifications
		/// </summary>
		public void SubscribeUserToDefaultNotifications(User user)
		{
			if (user == null)
			{
				throw new ArgumentNullException("user");
			}

			if (user.UserNotificationTypes == null)
			{
				user.UserNotificationTypes = new List<UserNotificationType>();
			}

			user.UserNotificationTypes.Add(new UserNotificationType {NotificationTypeId = (int) NotificationType.RecipeComment, DateCreated = DateTime.Now });
			user.UserNotificationTypes.Add(new UserNotificationType {NotificationTypeId = (int) NotificationType.BrewerFollowed, DateCreated = DateTime.Now });
			user.UserNotificationTypes.Add(new UserNotificationType { NotificationTypeId = (int)NotificationType.SiteFeatures, DateCreated = DateTime.Now });
		}
Пример #6
0
		/// <summary>
		/// Registers a new User
		/// </summary>
		public User RegisterNewUser(string fullName, string emailAddress, string password)
		{
			if(string.IsNullOrWhiteSpace(fullName))
			{
				throw new ArgumentNullException("fullName");
			}

			if(string.IsNullOrWhiteSpace(emailAddress))
			{
				throw new ArgumentNullException("emailAddress");
			}

			if(string.IsNullOrWhiteSpace(password))
			{
				throw new ArgumentNullException("password");
			}

			var nameParts = fullName.Split(' ');

			var user = new User
			{
				FirstName = nameParts.First(),
				LastName = string.Join(" ", nameParts.Skip(1)),
				EmailAddress = emailAddress,
				Password = this.Hasher.Hash(password),
				IsActive = true,
				Username = Guid.NewGuid().ToString().Replace("-",""),
				HasCustomUsername = false,
				DateCreated = DateTime.Now
			};

			this.SubscribeUserToDefaultNotifications(user);

			this.Repository.Add(user);

			return user;
		}