Esempio n. 1
0
        public static bool SendMail(string mailSubject, string mailBody, User user, Item item = null, User askUser = null)
        {
            mailBody = mailBody.Replace("USERNAME", user.Username);
            mailBody = mailBody.Replace("PASSWORD", user.Password);

            if (item != null)
            {
                mailBody = mailBody.Replace("BID_ID", item.BidCID.ToString());
                mailBody = mailBody.Replace("PRODUCT_NAME", item.Product);
                mailBody = mailBody.Replace("FIRST_PRICE", item.FirstPrice.ToString());
            }

            if (askUser != null) // TBD - case of no asks
            {
                mailBody = mailBody.Replace("FIRST_ASK_USER", askUser.Username);
                mailBody = mailBody.Replace("FIRST_ASK_PHONE", askUser.Phone.ToString());
            }

            var retVal = PostMail(user.Email, mailSubject, mailBody);

            return retVal;
        }
Esempio n. 2
0
        private void InitUsers()
        {
            // Bid
            User user1 = new User()
            {
                Username = "******",
                Password = "******",
                Email = "*****@*****.**",
                CID = 1,
                IsEmailUpdates = true,
                Phone = "052-610235454"
            };

            CIDToUserDataDic.Add(user1.CID, new UserData() {User = user1, BidIdList = new List<int>()});

            // Bid
            User user2 = new User()
            {
                Username = "******",
                Password = "******",
                Email = "*****@*****.**",
                CID = 2,
                IsEmailUpdates = true,
                Phone = "052-610235454"
            };

            CIDToUserDataDic.Add(user2.CID, new UserData() { User = user2, BidIdList = new List<int>() });

            // Ask
            User user3 = new User()
            {
                Username = "******",
                Password = "******",
                Email = "*****@*****.**",
                CID = 3,
                IsEmailUpdates = true,
                Phone = "052-610235454"
            };

            CIDToUserDataDic.Add(user3.CID, new UserData() { User = user3, AskIdList = new List<int>() });

            var i = 0;
            var items = DAL.instance.GetItems();
            foreach (var itemPair in items)
            {
                var item = itemPair.Value;
                i++;
                if (i % 2 == 0)
                {
                    item.BidCID = user2.CID;
                    CIDToUserDataDic[user2.CID].BidIdList.Add(item.Id);
                }
                else
                {
                    item.BidCID = user1.CID;
                    CIDToUserDataDic[user1.CID].BidIdList.Add(item.Id);
                }

                item.FirstAskCID = user3.CID;
                CIDToUserDataDic[user3.CID].AskIdList.Add(item.Id);

                int result = DateTime.Compare(DateTime.Now, item.DueDate);
                bool isBidEnded = result > 0;
                item.IsBidEnded = isBidEnded;
            }
        }
Esempio n. 3
0
        // Register //
        public User AddUser(RegisterRequest registerRequest)
        {
            User existedUser = GetUserByUsername(registerRequest.Username);
            if (existedUser == null)
            {
                var user = new User()
                {
                    CID = CreateUserCId(),
                    Username = registerRequest.Username,
                    Password = registerRequest.Password,
                    Email = registerRequest.Email.ToLower()
                };

                CIDToUserDataDic.Add(user.CID, new UserData() { User = user });

                return user;
            }

            return null;
        }
Esempio n. 4
0
        void SendEmail(User user, int productId, Item item)
        {
            try
            {
                string mailSubject = "מכרז חדש נפתח באתר בידיט";
                string mailBody = EmailTemplate.BidStartedEmail;

                // Sending an email
                var isMailSent = EmailSender.SendMail(mailSubject, mailBody, user, item);
            }
            catch (Exception ex)
            {
            }
        }