Exemplo n.º 1
0
        public void SendEmailAboutHigherBid(BidDTO previousBid)
        {
            Bid newBid = efu.Bids.Find(x => x.LotId == previousBid.LotId).OrderByDescending(x => x.CreatedDateTime).FirstOrDefault();

            int  previousUserId = previousBid.CreatedBy;
            User previousUser   = efu.Users.Get(previousUserId);

            int lotId = previousBid.LotId;
            Lot lot   = efu.Lots.Get(lotId);

            if (previousUser.GetLetters == true)
            {
                MailAddress from = new MailAddress(Configuration.Email, "Auction");
                MailAddress to   = new MailAddress(previousUser.Email);
                MailMessage m    = new MailMessage(from, to);

                m.Subject    = "Higher bid";
                m.Body       = "<p>There is a bid higher than yours for this lot:</p>";
                m.Body      += "<p>Name: " + lot.Name + "</p>";
                m.Body      += "<p>Description: " + lot.Description + "</p>";
                m.Body      += "<p>Initial Price: " + lot.InitialPrice + "</p>";
                m.Body      += "<p>Your Price: " + previousBid.BidPrice + "Time: " + previousBid.CreatedDateTime + " </p>";
                m.Body      += "<p>New Price: " + newBid.BidPrice + "Time: " + newBid.CreatedDateTime + " </p>";
                m.IsBodyHtml = true;

                AuctionSmtpClient.Send(m);
            }
        }
Exemplo n.º 2
0
        public void SendEmail(int lotId)
        {
            Lot  lot       = efu.Lots.Get(lotId);
            User userOwner = efu.Users.Get(lot.CreatedBy);
            IEnumerable <Bid> bidsFromDB = efu.Bids.Find(x => x.LotId == lotId);
            Bid  lastBid    = bidsFromDB.OrderByDescending(x => x.CreatedDateTime).FirstOrDefault();
            User userWinner = efu.Users.Get(lastBid.CreatedBy);

            if (userOwner.GetLetters == true)
            {
                MailAddress from1 = new MailAddress(Configuration.Email, "Auction");
                MailAddress to1   = new MailAddress(userOwner.Email);
                MailMessage m1    = new MailMessage(from1, to1);

                m1.Subject = "Your lot is closed";
                m1.Body    = "<p>Your lot is closed. Information about lot:</p>";
                m1.Body   += "<p>Name: " + lot.Name + "</p>";
                m1.Body   += "<p>Description: " + lot.Description + "</p>";
                m1.Body   += "<p>Initial Price: " + lot.InitialPrice + "</p>";
                m1.Body   += "<p>Last Price: " + lastBid.BidPrice + "Time: " + lastBid.CreatedDateTime + " </p>";
                m1.Body   += "<p>History of bids:</p>";

                foreach (Bid bid in bidsFromDB)
                {
                    m1.Body += "<p>" + bid.BidPrice + "       " + bid.CreatedDateTime + "</p>";
                }
                m1.IsBodyHtml = true;

                AuctionSmtpClient.Send(m1);
            }

            if (userWinner.GetLetters == true)
            {
                MailAddress from = new MailAddress(Configuration.Email, "Auction");
                MailAddress to   = new MailAddress(userWinner.Email);
                MailMessage m    = new MailMessage(from, to);

                m.Subject    = "You won the lot";
                m.Body       = "<p>You won the lot. Information about lot:</p>";
                m.Body      += "<p>Name: " + lot.Name + "</p>";
                m.Body      += "<p>Description: " + lot.Description + "</p>";
                m.Body      += "<p>Initial Price: " + lot.InitialPrice + "</p>";
                m.Body      += "<p>Your Price: " + lastBid.BidPrice + "Time: " + lastBid.CreatedDateTime + " </p>";
                m.Body      += "<p>The money has been debited from your account.</p>";
                m.IsBodyHtml = true;

                AuctionSmtpClient.Send(m);
            }
        }