コード例 #1
0
        public IActionResult GetCommisionById(int CommisionId)
        {
            //Write a code to GetCommisionById
            CommissionDetails CommissionDetails = new CommissionDetails();

            return(View());
        }
コード例 #2
0
        //Email sent to requester so that the requester can verify that they have sent a request.
        public void UserConfirmationMail(CommissionDetails commission)
        {
            string to   = commission.email;
            string body = $"Your request has been received. The following is the description of your request: \n {commission.description}. I will look over your commission request and see what I can do. ";

            string      subject        = $"Commission confirmation";
            MailMessage mail           = new MailMessage();
            string      senderEmail    = EmailCredentials.EmailAddress;
            string      senderPassword = EmailCredentials.Password;


            mail.From = new MailAddress(senderEmail);
            mail.To.Add(to);
            mail.Body       = body;
            mail.IsBodyHtml = true;
            mail.Subject    = subject;


            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

            smtp.Credentials = new NetworkCredential(senderEmail, senderPassword);
            smtp.EnableSsl   = true;

            smtp.Send(mail);
        }
コード例 #3
0
        internal int addCommission(CommissionDetails commission)
        {
            //Create connection
            string        connStr = configuration.GetConnectionString("MyConnString");
            SqlConnection conn    = new SqlConnection(connStr);

            conn.Open();


            //SQL Query for inserting commissions into database
            string query = "INSERT INTO [dbo].[CommissionsList]([email],[description])" +
                           " VALUES( @email, @description)";
            SqlCommand cmd = new SqlCommand(query, conn);

            cmd.Parameters.AddWithValue("@email", commission.email);
            cmd.Parameters.AddWithValue("@description", commission.description);

            //Query
            SqlDataReader reader = cmd.ExecuteReader();

            reader.Read();

            //creates user ID
            int uID = 1;

            conn.Close(); //Closes the connection

            return(uID);
        }
コード例 #4
0
        public IActionResult Page2(CommissionDetails commission)
        {
            DALCommission dp  = new DALCommission(configuration);
            int           uID = dp.addCommission(commission);

            this.UserConfirmationMail(commission);
            this.SendEmail(commission);
            return(View(commission));
        }
コード例 #5
0
        public void TestFor_GetCommissionById()
        {
            CommissionDetails CommissionDetails = new CommissionDetails()
            {
                CommisionId = 1,
            };
            //Arrange
            //Action
            var commitionById = _AdminService.GetCommisionById(CommissionDetails.CommisionId);

            //Assert
            Assert.NotNull(commitionById);
        }
コード例 #6
0
        //Commission Message to me
        public void SendEmail(CommissionDetails commission)
        {
            string to   = "*****@*****.**";
            string body = $"{commission.description} \n. Send results to {commission.email} upon completion. ";

            string      subject        = $"Commission from {commission.email}";
            MailMessage mail           = new MailMessage();
            string      senderEmail    = EmailCredentials.EmailAddress;
            string      senderPassword = EmailCredentials.Password;

            mail.From = new MailAddress(senderEmail);
            mail.To.Add(to);
            mail.Body       = body;
            mail.IsBodyHtml = true;
            mail.Subject    = subject;

            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

            smtp.Credentials = new NetworkCredential(senderEmail, senderPassword);
            smtp.EnableSsl   = true;

            smtp.Send(mail);
        }
コード例 #7
0
        public CommissionDetails GetCommisionById(int CommisionId)
        {
            CommissionDetails CommissionDetails = new CommissionDetails();

            return(CommissionDetails);
        }