示例#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
 public void Create(TbUser user)
 {
     SqlCommand cmd = con.CreateCommand();
     cmd.CommandText = "Insert Into TbUser (UserName,Email,Password,Status,RegisterDate) values (@UserName,@Email,@Password,@Status,@RegisterDate)";
     cmd.Parameters.AddWithValue("@UserName", user.UserName);
     cmd.Parameters.AddWithValue("@Email", user.Email);
     cmd.Parameters.AddWithValue("@Password", user.Password);
     cmd.Parameters.AddWithValue("@Status", user.Status);
     cmd.Parameters.AddWithValue("@RegisterDate", user.RegisterDate);
     cmd.ExecuteNonQuery();
 }
示例#3
0
 public MethodResult Register(string userName, string email, string password)
 {
     try
     {
         TbUser user = new TbUser() { UserName = userName, Email = email, Password = password };
         Business.User.Register(user);
         return new MethodResult(false, "ثبت نام با موفقیت انجام شد", null);
     }
     catch (HabbeException e)
     {
         return new MethodResult(true, e.Message, null);
     }
 }
示例#4
0
 public static TbUser ToEntity(System.Data.IDataReader reader)
 {
     TbUser user = null;
     user = new TbUser();
     user.Id = Convert.ToInt32(reader["Id"]);
     user.UserName = reader["UserName"].ToString();
     if (reader["FirstName"] != DBNull.Value)
         user.FirstName = reader["FirstName"].ToString();
     if (reader["LastName"] != DBNull.Value)
         user.LastName = reader["LastName"].ToString();
     user.Email = reader["Email"].ToString();
     if (reader["PhoneNo"] != DBNull.Value)
         user.PhoneNo = reader["PhoneNo"].ToString();
     if (reader["Location"] != DBNull.Value)
         user.Location = reader["Location"].ToString();
     if (reader["Picture"] != DBNull.Value)
         user.Picture = reader["Picture"].ToString();
     if (reader["Status"] != DBNull.Value)
         user.Status = reader["Status"].ToString();
     user.RegisterDate = Convert.ToDateTime(reader["RegisterDate"]);
     user.Password = reader["Password"].ToString();
     return user;
 }
示例#5
0
 public MethodResult SaveProfile(string username, string firstname, string lastname, string email, string status,string picture)
 {
     try
     {
         TbUser user = new TbUser() { UserName = username, FirstName = firstname, LastName = lastname, Email = email, Status = status, Picture = picture };
         Business.User.SaveProfile(user);
         return new MethodResult(false, null, null);
     }
     catch (HabbeException e)
     {
         return new MethodResult(true, e.Message, null);
     }
 }
示例#6
0
文件: User.cs 项目: habeh/Home.Habbeh
 public static void SaveProfile(TbUser user)
 {
     using (DataAccess.User db = new DataAccess.User())
     {
         db.Update(user);
     }
 }
示例#7
0
文件: User.cs 项目: habeh/Home.Habbeh
 public void UpdatePassword(TbUser user)
   {
       SqlCommand cmd = con.CreateCommand();
       cmd.CommandText = "Update TbUser set Password=@Password where UserName=@UserName";
       cmd.Parameters.AddWithValue("@UserName", user.UserName);
       cmd.Parameters.AddWithValue("@Password", user.Password );
       cmd.ExecuteNonQuery();
   }
示例#8
0
文件: User.cs 项目: habeh/Home.Habbeh
        public void Update(TbUser user)
        {
            SqlCommand cmd = con.CreateCommand();
            cmd.CommandText = "Update TbUser set FirstName=@FirstName , LastName=@LastName,Status=@Status,Email=@Email,Picture=@Picture where UserName=@UserName";
            cmd.Parameters.AddWithValue("@UserName", user.UserName);
            cmd.Parameters.AddWithValue("@FirstName", user.FirstName);
            cmd.Parameters.AddWithValue("@LastName", user.LastName);
            cmd.Parameters.AddWithValue("@Status", user.Status);
            cmd.Parameters.AddWithValue("@Email", user.Email);
            cmd.Parameters.AddWithValue("@Picture", user.Picture);

            cmd.ExecuteNonQuery();
        }