public static int Add(CommAddRequest model, string userId)
        {
            int id = 0;

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Communications_Insert"
               , inputParamMapper: delegate(SqlParameterCollection paramCollection)
               {
                   paramCollection.AddWithValue("@Name", model.Name);
                   paramCollection.AddWithValue("@Email", model.Email);
                   paramCollection.AddWithValue("@Subject", model.Subject);
                   paramCollection.AddWithValue("@Message", model.Message);
                   paramCollection.AddWithValue("@UserId", userId);

                   SqlParameter p = new SqlParameter("@Id", System.Data.SqlDbType.Int);
                   p.Direction = System.Data.ParameterDirection.Output;

                   paramCollection.Add(p);
               }
               , returnParameters: delegate(SqlParameterCollection param)
               {
                   int.TryParse(param["@Id"].Value.ToString(), out id);
               }
               );
            return id;
        }
        public HttpResponseMessage SendMail(CommAddRequest model)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            string userId = _userService.GetCurrentUserId();

            ItemResponse<int> response = new ItemResponse<int>();

            response.Item = CommunicationsService.Add(model, userId);

            MailService.SendContactUs(model);

            return Request.CreateResponse(response);
        }
Пример #3
0
        public static void SendContactUs(CommAddRequest requestModel)
        {
            //this method should accept contact add request and create email data
            //using the data within contact add request
            EmailData model = new EmailData();

            //put data into email data

            model.FromEmail = requestModel.Email;
            model.Name = requestModel.Name;
            model.Subject = requestModel.Subject;
            model.Message = requestModel.Message;

            //The intro message needs to be sent to Admin ONLY.
            //plus '/n' formats the text size and 'Environment.NewLine' fails to insert new line as expected.

            //model.Message = "Hello Admin," + Environment.NewLine + "This email has been sent to you from a Site User who filled out your 'Contact Us' form." + Environment.NewLine + Environment.NewLine;
            //model.Message += requestModel.Message;

            model.To = ("000000000000000");
            model.CC = requestModel.Email;

            Send(model);
        }