using MailKit.Net.Smtp;
using MimeKit;
using System;
using System.Linq;
using System.Linq.Dynamic.Core;
using UnivateProperties_API.Context;
using UnivateProperties_API.Model.Communication;
namespace UnivateProperties_API.Repository.Communication
{
    public interface IMailRepository
    {
        void ContactUs(MailModel mm);
        void EnquireNow(MailModel mm);
    }
    public class MailRepository : IMailRepository
    {
        private readonly DataContext _dbContext;
        public MailRepository(DataContext db)
        {
            _dbContext = db;
        }
        MimeMessage messageObj = new MimeMessage();
        MailboxAddress from;
        MailboxAddress to;
        BodyBuilder bodyBuilder = new BodyBuilder();
        SmtpClient client = new SmtpClient();
        public void ContactUs(MailModel mm)
        {
            string property = mm.Property;
            string phone = mm.Phone;
            string name = mm.Name;
            string email = mm.Email;
            string message = mm.Message;
            from = new MailboxAddress("Admin", mm.FromAddress);
            to = new MailboxAddress("User", mm.ToAddress);
            messageObj.From.Add(from);
            messageObj.To.Add(to);
            messageObj.Subject = "Uni-Vate - New Contact Request";
            bodyBuilder.HtmlBody = "
" +
                "
Contact from: "+  name +"!
" +
                "
Email: "+ email +"
" +
                "
Phone: " + phone + "
" +
                "
Property: " + property + "
" +
                "
" +
                "
Message: 
" +
                "
" + message + "
" +
                "
" +
                "
" +
                "
Contact from: " + name + "!
" +
                "
Email: " + email + "
" +
                "
Phone: " + phone + "
" +
                "
" +
                "
Property: 
" +
                "
" + prop.Id + "
" +
                "
" + prop.PropertyName + "
" +
                "
" + prop.PropertyRef + "
" +
                "
" + prop.Price + "
" +
                "
" +
                "