Beispiel #1
0
        /// <summary>
        /// Saves user feedback.
        /// </summary>
        /// <param name="user"></param>
        /// <param name="userFeedback"></param>
        /// <returns></returns>
        public void SaveUserFeedback(UserFeedbackContext context, Core.Models.UserFeedback.UserFeedback userFeedback)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (userFeedback == null)
            {
                throw new ArgumentNullException("userFeedback");
            }

            AssertUserFeedback(userFeedback);

            _userFeedbackRepo.SaveUserFeedback(context, userFeedback);
        }
Beispiel #2
0
        /// <summary>
        /// Validates all of the attributes of the user's feedback.
        /// </summary>
        /// <remarks>
        /// </remarks>
        private void AssertUserFeedback(Core.Models.UserFeedback.UserFeedback userFeedback)
        {
            if (userFeedback.Subject.Length == 0)
            {
                throw new ApplicationException("Subject is blank.");
            }

            if (userFeedback.Content.Length == 0)
            {
                throw new ApplicationException("Content is blank.");
            }

            if (Enum.IsDefined(typeof(Audience), userFeedback.Audience) == false)
            {
                throw new ApplicationException("Audience value is invalid.");
            }
        }
Beispiel #3
0
        /// <summary>
        ///     Create a feedback row for the user
        /// </summary>
        /// <param name="user"></param>
        /// <param name="userFeedback"></param>
        public void SaveUserFeedback(UserFeedbackContext context, Core.Models.UserFeedback.UserFeedback userFeedback)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (userFeedback == null)
            {
                throw new ArgumentNullException("userFeedback");
            }

            string sqlCommand = @"
	            INSERT INTO [Messaging].[UserFeedback]
		            (
		            [UserId]
		            ,[UserFirstName]
		            ,[UserLastName]
		            ,[BranchId]	
		            ,[CustomerNumber]
		            ,[CustomerName]
		            ,[SalesRepName]
		            ,[Audience]
		            ,[SourceName]
		            ,[TargetName]
		            ,[SourceEmailAddress]
		            ,[TargetEmailAddress]
		            ,[Subject]
		            ,[Content]
		            ,[BrowserUserAgent]
		            ,[BrowserVendor]
		            )
	            OUTPUT Inserted.Id
	            VALUES
		            (
		            @UserId	
		            ,@UserFirstName
		            ,@UserLastName
		            ,@BranchId
		            ,@CustomerNumber
		            ,@CustomerName
		            ,@SalesRepName
		            ,@Audience
		            ,@SourceName
		            ,@TargetName
		            ,@SourceEmailAddress
		            ,@TargetEmailAddress

		            ,@Subject
		            ,@Content

		            ,@BrowserUserAgent
		            ,@BrowserVendor
		            )

                SELECT SCOPE_IDENTITY()
                ";

            var parameters =
                new
            {
                UserId             = context.UserId,
                UserFirstName      = context.UserFirstName,
                UserLastName       = context.UserLastName,
                BranchId           = context.BranchId,
                CustomerNumber     = context.CustomerNumber,
                CustomerName       = context.CustomerName,
                SalesRepName       = context.SalesRepName,
                SourceName         = context.SourceName,
                TargetName         = context.TargetName,
                SourceEmailAddress = context.SourceEmailAddress,
                TargetEmailAddress = context.TargetEmailAddress,

                Subject = userFeedback.Subject,
                Content = userFeedback.Content,

                Audience         = userFeedback.Audience.ToString(),
                BrowserUserAgent = userFeedback.BrowserUserAgent,
                BrowserVendor    = userFeedback.BrowserVendor,
            };

            _dbConnection.Execute(sqlCommand, parameters);
        }