Пример #1
0
        public async Task <long> Save(DriverAccount entity)
        {
            _context.Entry(entity).State = entity.Id > 0 ? EntityState.Modified : EntityState.Added;
            await _context.SaveChangesAsync();

            return(entity.Id);
        }
Пример #2
0
 private dynamic GetEmailBodyDataForDriverSignUpConfirmationLink(DriverAccount account, string token)
 {
     return(new
     {
         name = account.Firstname,
         url = $"{FrontendConfiguration.Url}driver-signup-confirmation?email={account.AppUser.UserName}&token={token}"
     });
 }
Пример #3
0
        public async Task <long> Delete(long id)
        {
            DriverAccount driverAccount = await GetById(id);

            _context.DriverAccounts.Remove(driverAccount);
            await _context.SaveChangesAsync();

            return(id);
        }
Пример #4
0
        public async Task SendDriverSignUpMailAsync(DriverAccount account)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            var passwordResetToken = await UserManager.GeneratePasswordResetTokenAsync(account.AppUser);

            passwordResetToken = Uri.EscapeDataString(passwordResetToken);

            var templateId   = EmailTemplateIds.DriverSignUpConfirmationLink;
            var templateData = GetEmailBodyDataForDriverSignUpConfirmationLink(account, passwordResetToken);
            await EmailService.SendEmailWithSendGridTemplateAsync(account.AppUser.Email, $"{account.Firstname} {account.Lastname}", templateId, templateData);
        }
Пример #5
0
        public DataTable ChangePassword(DriverAccount U)
        {
            int            status      = 0;
            DataTable      dt          = new DataTable();
            LogTraceWriter traceWriter = new LogTraceWriter();
            SqlConnection  conn        = new SqlConnection();

            try
            {
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "ChangePassword....");
                StringBuilder str = new StringBuilder();
                str.Append("@Mobilenumber" + U.Mobilenumber + ",");
                str.Append("@Email" + U.Email + ",");
                str.Append("@Password" + U.Password + ",");
                str.Append("@NewPassword" + U.NewPassword + ",");

                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "ChangePassword Input sent...." + str.ToString());

                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "PSDriversChangePwd";

                cmd.Connection = conn;

                SqlParameter b1 = new SqlParameter("@Mobilenumber", SqlDbType.VarChar, 20);
                b1.Value = U.Mobilenumber;
                cmd.Parameters.Add(b1);

                SqlParameter e = new SqlParameter("@Email", SqlDbType.VarChar, 50);
                e.Value = U.Email;
                cmd.Parameters.Add(e);


                SqlParameter m = new SqlParameter("@Password", SqlDbType.VarChar, 50);
                m.Value = U.Password;
                cmd.Parameters.Add(m);

                SqlParameter m1 = new SqlParameter("@NewPassword", SqlDbType.VarChar, 50);
                m1.Value = U.NewPassword;
                cmd.Parameters.Add(m1);

                SqlDataAdapter ds = new SqlDataAdapter(cmd);
                ds.Fill(dt);
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "ChangePassword successful....");
            }
            catch (Exception ex)
            {
                traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "ChangePassword...." + ex.Message.ToString());
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message));
                dt.Columns.Add("Code");
                dt.Columns.Add("description");
                DataRow dr = dt.NewRow();
                dr[0] = "ERR001";
                dr[1] = ex.Message;
                dt.Rows.Add(dr);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);

            //Verify Passwordotp
        }
        public DataTable RegisterDrivers(DriverAccount ocr)
        {
            SqlConnection  conn        = new SqlConnection();
            LogTraceWriter traceWriter = new LogTraceWriter();
            DataTable      dt          = new DataTable();
            StringBuilder  str         = new StringBuilder();
            SqlTransaction transaction = null;

            try
            {
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Register Driver....");

                if (ocr == null)
                {
                    traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "invalid input sent");
                }

                str.Append("MobileNo:" + ocr.Mobilenumber + ",");
                str.Append("email:" + ocr.Email + ",");
                str.Append("password:"******",");
                str.Append("firstname:" + ocr.Firstname + ",");
                str.Append("lastname:" + ocr.lastname + ",");
                str.Append("authtypeid:" + ocr.AuthTypeId + ",");
                str.Append("countryid:" + ocr.CountryId + ",");
                str.Append("bioMetricData:" + ocr.bioMetricData + ",");
                str.Append(Environment.NewLine);
                str.Append("reg no:" + ocr.RegistrationNo + ",");
                str.Append("vtypeid:" + ocr.VehicleTypeId + ",");
                str.Append("vgroupid:" + ocr.VehicleGroupId + ",");
                str.Append("isdriverowned:" + ocr.isDriverOwned + ",");
                str.Append(Environment.NewLine);

                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Input sent...." + str.ToString());

                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "PSInsUpdAppDrivers";

                cmd.Connection = conn;

                SqlParameter f = new SqlParameter("@flag", SqlDbType.VarChar);
                f.Value = ocr.flag;
                cmd.Parameters.Add(f);

                SqlParameter cm = new SqlParameter("@Mobilenumber", SqlDbType.VarChar, 20);
                cm.Value = ocr.Mobilenumber;
                cmd.Parameters.Add(cm);

                SqlParameter e = new SqlParameter("@Email", SqlDbType.VarChar, 100);
                e.Value = ocr.Email;
                cmd.Parameters.Add(e);

                SqlParameter q1 = new SqlParameter("@Password", SqlDbType.VarChar, 50);
                q1.Value = ocr.Password;
                cmd.Parameters.Add(q1);

                SqlParameter v3 = new SqlParameter("@Firstname", SqlDbType.VarChar, 50);
                v3.Value = ocr.Firstname;
                cmd.Parameters.Add(v3);

                SqlParameter v1 = new SqlParameter("@lastname", SqlDbType.VarChar, 50);
                v1.Value = ocr.lastname;
                cmd.Parameters.Add(v1);

                SqlParameter v2 = new SqlParameter("@AuthTypeId", SqlDbType.Int);
                v2.Value = ocr.AuthTypeId;
                cmd.Parameters.Add(v2);

                SqlParameter c = new SqlParameter("@CountryId", SqlDbType.Int);
                c.Value = ocr.CountryId;
                cmd.Parameters.Add(c);

                SqlParameter u = new SqlParameter("@bioMetricData", SqlDbType.VarChar);
                u.Value = ocr.bioMetricData;
                cmd.Parameters.Add(u);

                SqlParameter p = new SqlParameter("@DPhoto", SqlDbType.VarChar, -1);
                p.Value = ocr.DPhoto;
                cmd.Parameters.Add(p);

                SqlParameter vg = new SqlParameter("@VehicleGroupId", SqlDbType.Int);
                vg.Value = ocr.VehicleGroupId;
                cmd.Parameters.Add(vg);

                SqlParameter bpa = new SqlParameter("@BusinessAppUserId", SqlDbType.Int);
                bpa.Value = ocr.BusinessAppUserId;
                cmd.Parameters.Add(bpa);

                SqlParameter Uac = new SqlParameter("@UserAccountNo", SqlDbType.VarChar, 50);
                Uac.Value = ocr.UserAccountNo;
                cmd.Parameters.Add(Uac);

                if (ocr.RegistrationNo != null && ocr.RegistrationNo != string.Empty)
                {
                    SqlParameter n = new SqlParameter("@RegistrationNo", SqlDbType.VarChar, 50);
                    n.Value = ocr.RegistrationNo;
                    cmd.Parameters.Add(n);

                    SqlParameter vt = new SqlParameter("@VehicleTypeId", SqlDbType.Int);
                    vt.Value = ocr.VehicleTypeId;
                    cmd.Parameters.Add(vt);

                    SqlParameter isDriverOwned = new SqlParameter("@isDriverOwned", SqlDbType.Int);
                    isDriverOwned.Value = ocr.isDriverOwned;
                    cmd.Parameters.Add(isDriverOwned);

                    SqlParameter vcode = new SqlParameter("@VPhoto ", SqlDbType.VarChar, -1);
                    vcode.Value = ocr.VPhoto;
                    cmd.Parameters.Add(vcode);
                }
                if (conn.State == ConnectionState.Closed)
                {
                    conn.Open();
                }
                transaction = conn.BeginTransaction();

                SqlDataAdapter da = new SqlDataAdapter(cmd);
                cmd.Transaction = transaction;

                da.Fill(dt);
                transaction.Commit();
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Register driver saved....");

                //[Mobileotp] ,[Emailotp]

                //send mobile otp as SMS
                #region Mobile OTP
                string motp = dt.Rows[0]["Mobileotp"].ToString();
                if (motp != null)
                {
                    try
                    {
                        MailMessage mail        = new MailMessage();
                        string      emailserver = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();

                        string username    = System.Configuration.ConfigurationManager.AppSettings["username"].ToString();
                        string pwd         = System.Configuration.ConfigurationManager.AppSettings["password"].ToString();
                        string fromaddress = System.Configuration.ConfigurationManager.AppSettings["fromaddress"].ToString();
                        string port        = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();

                        SmtpClient SmtpServer = new SmtpClient(emailserver);

                        mail.From = new MailAddress(fromaddress);
                        mail.To.Add(ocr.Email);
                        mail.Subject    = "Driver registration - Mobile OTP";
                        mail.IsBodyHtml = true;

                        string verifcodeMail = @"<table>
                                                        <tr>
                                                            <td>
                                                                <h2>Thank you for registering with PaySmart APP</h2>
                                                                <table width=\""760\"" align=\""center\"">
                                                                    <tbody style='background-color:#F0F8FF;'>
                                                                        <tr>
                                                                            <td style=\""font-family:'Zurich BT',Arial,Helvetica,sans-serif;font-size:15px;text-align:left;line-height:normal;background-color:#F0F8FF;\"" >
<div style='padding:10px;border:#0000FF solid 2px;'>    <br /><br />
                                                                             
                                                       Your Mobile OTP is:<h3>" + motp + @" </h3>

                                                        If you didn't make this request, <a href='http://154.120.237.198:52800'>click here</a> to cancel.

                                                                                <br/>
                                                                                <br/>             
                                                                       
                                                                                Warm regards,<br>
                                                                                PAYSMART Customer Service Team<br/><br />
</div>
                                                                            </td>
                                                                        </tr>

                                                                    </tbody>
                                                                </table>
                                                            </td>
                                                        </tr>

                                                    </table>";


                        mail.Body = verifcodeMail;
                        //SmtpServer.Port = 465;
                        //SmtpServer.Port = 587;
                        SmtpServer.Port = Convert.ToInt32(port);
                        SmtpServer.UseDefaultCredentials = false;

                        SmtpServer.Credentials = new System.Net.NetworkCredential(username, pwd);
                        SmtpServer.EnableSsl   = true;
                        //SmtpServer.TargetName = "STARTTLS/smtp.gmail.com";
                        SmtpServer.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "Register driver Email otp failed...." + ex.Message);
                        //throw ex;
                    }
                }
                #endregion Mobile OTP

                //send email otp\
                #region email opt
                string eotp = dt.Rows[0]["Emailotp"].ToString();
                if (eotp != null)
                {
                    try
                    {
                        MailMessage mail        = new MailMessage();
                        string      emailserver = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();

                        string username    = System.Configuration.ConfigurationManager.AppSettings["username"].ToString();
                        string pwd         = System.Configuration.ConfigurationManager.AppSettings["password"].ToString();
                        string fromaddress = System.Configuration.ConfigurationManager.AppSettings["fromaddress"].ToString();
                        string port        = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();

                        SmtpClient SmtpServer = new SmtpClient(emailserver);

                        mail.From = new MailAddress(fromaddress);
                        mail.To.Add(ocr.Email);
                        mail.Subject    = "Driver registration - Email OTP";
                        mail.IsBodyHtml = true;

                        string verifcodeMail = @"<table>
                                                        <tr>
                                                            <td>
                                                                <h2>Thank you for registering with PaySmart APP</h2>
                                                                <table width=\""760\"" align=\""center\"">
                                                                    <tbody style='background-color:#F0F8FF;'>
                                                                        <tr>
                                                                            <td style=\""font-family:'Zurich BT',Arial,Helvetica,sans-serif;font-size:15px;text-align:left;line-height:normal;background-color:#F0F8FF;\"" >
<div style='padding:10px;border:#0000FF solid 2px;'>    <br /><br />
                                                                             
                                                       Your email OTP is:<h3>" + eotp + @" </h3>

                                                        If you didn't make this request, <a href='http://154.120.237.198:52800'>click here</a> to cancel.

                                                                                <br/>
                                                                                <br/>             
                                                                       
                                                                                Warm regards,<br>
                                                                                PAYSMART Customer Service Team<br/><br />
</div>
                                                                            </td>
                                                                        </tr>

                                                                    </tbody>
                                                                </table>
                                                            </td>
                                                        </tr>

                                                    </table>";


                        mail.Body = verifcodeMail;
                        //SmtpServer.Port = 465;
                        //SmtpServer.Port = 587;
                        SmtpServer.Port = Convert.ToInt32(port);
                        SmtpServer.UseDefaultCredentials = false;

                        SmtpServer.Credentials = new System.Net.NetworkCredential(username, pwd);
                        SmtpServer.EnableSsl   = true;
                        //SmtpServer.TargetName = "STARTTLS/smtp.gmail.com";
                        SmtpServer.Send(mail);
                    }
                    catch (Exception ex)
                    {
                        traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "Register driver Email otp failed...." + ex.Message);
                        //throw ex;
                    }
                }

                //send mobile otp


                // return dt;

                #endregion email otp

                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Registerdriver successful....");
            }
            catch (Exception ex)
            {
                traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "Register driver...." + ex.Message.ToString());
                transaction.Rollback();
                //throw InnerException;
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message));
                dt.Columns.Add("Code");
                dt.Columns.Add("description");
                DataRow dr = dt.NewRow();
                dr[0] = "ERR001";
                dr[1] = ex.Message;
                dt.Rows.Add(dr);
            }

            finally
            {
                transaction.Dispose();
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);
        }
Пример #7
0
        public DataTable Forgotpassword(DriverAccount ocr)
        {
            int            Status      = 0;
            DataTable      dt          = new DataTable();
            LogTraceWriter traceWriter = new LogTraceWriter();
            SqlConnection  conn        = new SqlConnection();

            try
            {
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Forgotpassword....");
                StringBuilder str = new StringBuilder();
                str.Append("@mobileno" + ocr.Mobilenumber + ",");
                str.Append("@Email" + ocr.Email + ",");

                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Forgotpassword Input sent...." + str.ToString());

                conn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["btposdb"].ToString();

                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "PSDriversForgotPassword";

                cmd.Connection = conn;

                SqlParameter c = new SqlParameter("@mobileno", SqlDbType.VarChar, 20);
                c.Value = ocr.Mobilenumber;
                cmd.Parameters.Add(c);

                SqlParameter a = new SqlParameter("@Email", SqlDbType.VarChar, 50);
                a.Value = ocr.Email;
                cmd.Parameters.Add(a);

                SqlDataAdapter ds = new SqlDataAdapter(cmd);
                ds.Fill(dt);

                #region password otp
                string potp = dt.Rows[0]["Passwordotp"].ToString();
                if (potp != null)
                {
                    try
                    {
                        MailMessage mail        = new MailMessage();
                        string      emailserver = System.Configuration.ConfigurationManager.AppSettings["emailserver"].ToString();

                        string username    = System.Configuration.ConfigurationManager.AppSettings["username"].ToString();
                        string pwd         = System.Configuration.ConfigurationManager.AppSettings["password"].ToString();
                        string fromaddress = System.Configuration.ConfigurationManager.AppSettings["fromaddress"].ToString();
                        string port        = System.Configuration.ConfigurationManager.AppSettings["port"].ToString();

                        SmtpClient SmtpServer = new SmtpClient(emailserver);

                        mail.From = new MailAddress(fromaddress);
                        mail.To.Add(ocr.Email);
                        mail.Subject    = "User registration - Password OTP";
                        mail.IsBodyHtml = true;

                        string verifcodeMail = @"<table>
                                                        <tr>
                                                            <td>
                                                                <h2>Thank you for registering with PaySmart APP</h2>
                                                                <table width=\""760\"" align=\""center\"">
                                                                    <tbody style='background-color:#F0F8FF;'>
                                                                        <tr>
                                                                            <td style=\""font-family:'Zurich BT',Arial,Helvetica,sans-serif;font-size:15px;text-align:left;line-height:normal;background-color:#F0F8FF;\"" >
<div style='padding:10px;border:#0000FF solid 2px;'>    <br /><br />
                                                                             
                                                       Your email OTP is:<h3>" + potp + @" </h3>

                                                        If you didn't make this request, <a href='http://154.120.237.198:52800'>click here</a> to cancel.

                                                                                <br/>
                                                                                <br/>             
                                                                       
                                                                                Warm regards,<br>
                                                                                PAYSMART Customer Service Team<br/><br />
</div>
                                                                            </td>
                                                                        </tr>

                                                                    </tbody>
                                                                </table>
                                                            </td>
                                                        </tr>

                                                    </table>";


                        mail.Body = verifcodeMail;
                        //SmtpServer.Port = 465;
                        //SmtpServer.Port = 587;
                        SmtpServer.Port = Convert.ToInt32(port);
                        SmtpServer.UseDefaultCredentials = false;

                        SmtpServer.Credentials = new System.Net.NetworkCredential(username, pwd);
                        SmtpServer.EnableSsl   = true;
                        //SmtpServer.TargetName = "STARTTLS/smtp.gmail.com";
                        SmtpServer.Send(mail);
                        Status = 1;
                    }
                    catch (Exception ex)
                    {
                        //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                    }
                    finally
                    {
                        conn.Close();
                    }
                    #endregion password otp
                }

                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Forgotpassword successful....");
            }
            catch (Exception ex)
            {
                traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "Forgotpassword...." + ex.Message.ToString());
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.OK, ex.Message));
                dt.Columns.Add("Code");
                dt.Columns.Add("description");
                DataRow dr = dt.NewRow();
                dr[0] = "ERR001";
                dr[1] = ex.Message;
                dt.Rows.Add(dr);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);
        }
Пример #8
0
 public SwabJobMatchSpecification(DriverAccount driverAccount)
     : base(jobMatch => jobMatch.DriverAccountId == driverAccount.Id)
 {
     AddIncludes();
 }