/// <summary>
 /// Send course owner request for join his course.
 /// </summary>
 /// <param name="course">The course details.</param>
 /// <param name="requestBy">the user that request join the course.</param>
 public static void SendApproveRequest(Course course, User requestBy)
 {
     if (course == null || requestBy == null)
         return;
     User user = CMDal.GetUserBy("Id", course.CourseAdminID);
     string template = GetEmailTamplateByType(EmailType.ApproveRequest);
     template = string.Format(template, user.UserName,requestBy.UserName, course.CourseName);
     SendMail(user.Email, "Your Action Is Required", template);
 }
        public bool RegisterREST(User user, out int userId, out string sessionId)
        {
            sessionId = string.Empty;
            SQLStatus status = CMDal.RegisterNewUser(user, out userId);

            if (status == SQLStatus.Succeeded)
            {
                sessionId = CMDal.GetNewSession(userId);
                return true;
            }
            return false;
        }
示例#3
0
 public SQLStatus Register(User user, out int userId, out string sessionId)
 {
     sessionId = string.Empty;
     SQLStatus status = CMDal.RegisterNewUser(user, out userId);
     if (status == SQLStatus.Succeeded)
     {
         sessionId = CMDal.GetNewSession(userId);
         NotificationUtilitys.SendVerifyMail(user);
         CMDal.InsertNewAction(userId, (int)LinkType.EmailVerify);
     }
     return status;
 }
示例#4
0
        public static SQLStatus RegisterNewUser(User user, out int userId)
        {
            userId = -1;
            try
            {
                DataTable table = new DataAccess(ConnectionString).ExecuteQuerySP("SP_Register",
                        "@FirstName", user.FirstName,
                        "@LastName", user.LastName,
                        "@Email", user.Email,
                        "@Password", user.Password,
                        "@GCMid", user.GCMId,
                        "@UserName", user.UserName);
                if (table == null || table.Rows.Count == 0)
                    return SQLStatus.Failed;

                if (!ParseCellDataToInt(table.Rows[0]["UserID"], out userId))
                    return SQLStatus.Failed;
                switch (userId)
                {
                    case -1:
                        return SQLStatus.UserExists;
                    case -2:
                        return SQLStatus.EmailExists;
                    default:
                        return SQLStatus.Succeeded;
                }
            }
            catch (Exception)
            {
                return SQLStatus.Failed;
            }
        }
示例#5
0
        public static User GetUserBy(params object[] parameters)
        {
            StringBuilder query = new StringBuilder("SELECT * FROM tblUser");
            if (parameters.Length < 2)
                return null;

            query.Append(" WHERE ");

            for (int i = 0; i < parameters.Length-1; i++)
            {
                query.Append(parameters[i] + "='" + parameters[i + 1]+"'");
            }

            DataTable table = new DataAccess(ConnectionString).ExecuteQueryDS(query.ToString());
            if (table == null || table.Rows.Count == 0)
                return null;

            int id;
            ParseCellDataToInt(table.Rows[0]["Id"], out id);

            User toReturn = new User()
            {
                ID=id,
                Email =ParseCellDataToString(table.Rows[0]["Email"]),
                FirstName=ParseCellDataToString(table.Rows[0]["FirstName"]),
                LastName = ParseCellDataToString(table.Rows[0]["LastName"]),
                UserName = ParseCellDataToString(table.Rows[0]["UserName"]),
                GCMId = ParseCellDataToString(table.Rows[0]["GCMId"]),
                Password = ParseCellDataToString(table.Rows[0]["Password"])
            };

            return toReturn;
        }
示例#6
0
        public static List<User> GetCoursePartisipant(string sessionId, int userId, int courseId)
        {
            List<User> toReturn = new List<User>();

            try
            {
                DataTable table = new DataAccess(ConnectionString).ExecuteQuerySP("SP_ReturnParticipantsByCourseID",
                        "@SessionID", sessionId,
                        "@UserID", userId,
                        "@CourseID", courseId);

                if (table == null || table.Rows.Count == 0)
                    return toReturn;
                foreach (DataRow row in table.Rows)
                {
                    User u = new User();
                    u.FirstName = ParseCellDataToString(row["FirstName"]);
                    u.LastName = ParseCellDataToString(row["LastName"]);
                    u.UserName = ParseCellDataToString(row["UserName"]);
                    u.Email = ParseCellDataToString(row["Email"]);
                    bool x = false;
                    ParseCellDataToBool(row["IsAdmin"], out x);
                    u.IsAdmin = x;
                    int id = -1;
                    ParseCellDataToInt(row["Id"], out id);
                    u.ID = id;
                    toReturn.Add(u);
                }
                return toReturn;
            }
            catch (Exception)
            {
                return toReturn;
            }
        }
 /// <summary>
 /// Send verification email to user.
 /// </summary>
 /// <param name="sendTo">The user that the email send to.</param>
 public static void SendVerifyMail(User sendTo)
 {
     if (sendTo == null)
         return;
     string template = GetEmailTamplateByType(EmailType.Verify);
     template = string.Format(template, sendTo.UserName, Utilitys.GetUniqueEmail(LinkType.EmailVerify, sendTo));
     SendMail(sendTo.Email, "Verify Your Email", template);
 }
 /// <summary>
 /// Send reset passowrd email.
 /// </summary>
 /// <param name="user">The user need password reset.</param>
 public static void SendResetPasswordEmail(User sendTo)
 {
     if (sendTo == null)
         return;
     string template = GetEmailTamplateByType(EmailType.ResetPassword);
     template = string.Format(template, sendTo.UserName, Utilitys.GetUniqueEmail(LinkType.ResetPassword, sendTo));
     SendMail(sendTo.Email, "Reset Password", template);
 }