예제 #1
0
파일: User.cs 프로젝트: habeh/Home.Habbeh
        public static void Register(TbUser user)
        {
            using (DataAccess.User userData = new DataAccess.User())
            {
                Entity.TbUser newUser = new TbUser();
                newUser.UserName = user.UserName;
                newUser.Email = user.Email;
                newUser.Password = user.Password;
                newUser.Status = "I am Online In Habbeh";
                newUser.RegisterDate = DateTime.Now;

                /*Check Required Fields UserName,Email,Password*/
                if (string.IsNullOrEmpty(user.UserName)) { throw new HabbeException("نام کاربری اجباری است"); }
                if (string.IsNullOrEmpty(user.Email)) { throw new HabbeException("ایمیل اجباری است"); }
                if (string.IsNullOrEmpty(user.Password)) { throw new HabbeException("رمز عبور اجباری است"); }

                /*Check Duplicate UserName*/
                if (userData.Retrieve(user.UserName) != null)
                {
                    throw new HabbeException("نام کاربری تکراری است");
                }

                /*Check Duplicate Email */
                if (userData.RetrieveByEmail(user.Email) != null)
                {
                    throw new HabbeException("ایمیل تکراری است");
                }

                /*Create User*/
                userData.Create(newUser);
            }

            /*Send Verification Email*/
            SendEmail(user.Email, EmailType.Verification);
        }
예제 #2
0
파일: User.cs 프로젝트: habeh/Home.Habbeh
        private static void SendEmail(string email, EmailType emailType)
        {
            //TODO: Email Service, background Thread for send email 

            /*TODO : Create some recored in database*/

            switch (emailType)
            {
                case EmailType.Forgive:
                    using (DataAccess.User userData = new DataAccess.User())
                    {
                        TbUser user = userData.RetrieveByEmail(email);


                        SendEmail("<html><body><b>UserName :   <font color=red>" + user.UserName + "</font> <br> <font color=black> Password :</font> <font color=red>" + user.Password + "</font><br><font color=blue> Habbeh Android Application</font></body></html> ", email, "ایمیل یاداوری");
                    }
                    break;
                case EmailType.Verification:
                    SendEmail("ارسال ایمیل تایید ثبت نام", email, "ایمیل تایید ثبت نام");
                    break;
            }
        }