public IActionResult SendEmailWithHangFire([FromBody] SendEmailRequestModel model)
        {
            BackgroundJob.Enqueue(() => EmailService.SendEmailToManager(model.Email));
            BackgroundJob.Enqueue(() => EmailService.SendEmailToClient(model.Email));

            return(Ok());
        }
        public IActionResult SendEmail([FromBody] SendEmailRequestModel model)
        {
            EmailService.SendEmailToClient(model.Email);
            EmailService.SendEmailToManager(model.Email);

            return(Ok());
        }
 public string SendEmail(SendEmailRequestModel SERM)
 {
     string Result = "";
     try
     {
         MailMessage mail = new MailMessage();
         SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
         mail.From = new MailAddress("*****@*****.**");
         mail.To.Add(SERM.ToEmailId);
         mail.Subject = SERM.Subject;
         mail.Body = SERM.MessageBody;              
         SmtpServer.Port = 587;
         SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "testifiedpassword@hackfree");
         SmtpServer.EnableSsl = true;
         SmtpServer.Send(mail);
         Result = "Ok";
     }
     catch (Exception ex)
     {
         Result = Convert.ToString(ex);
     }
     return Result;
 }
        public async Task <IActionResult> SendEmail(SendEmailRequestModel emailRequestModel)
        {
            var sender = await this.userService.GetUserEmailById(this.currentUser.GetId());

            var result = await this.CheckIfUserExistsAsync(emailRequestModel.To);

            if (result == false)
            {
                return(this.BadRequest());
            }

            await this.emailSender.SendEmailAsync(sender, "BeatsWave", emailRequestModel.To, "Someone is interested in buying your beat!", emailRequestModel.HtmlContent);

            // Sending notification to the user
            var targetUser = await this.userService.GetUserByEmailAsync <UserByEmailServiceModel>(emailRequestModel.To);

            var notificationId = await this.notificationService.CreateAsync(targetUser.Id, this.currentUser.GetId(), string.Format(EmailNotification, this.currentUser.GetUserName()), "Email");

            var notification = await this.notificationService.GetNotificationById <NotificationsByUserServiceModel>(notificationId);

            await this.notificationHub.Clients.User(targetUser.Id).SendAsync("NewNotificationReceived", notification);

            return(this.Ok());
        }
        public ForgetPasswordResponseModel ForgetPassword(ForgetPasswordRequestModel model)
        {
            ForgetPasswordResponseModel FPRM = new ForgetPasswordResponseModel();

            try
            {
                Users UserValidEmailId   = _ObjDBContext.Users.FirstOrDefault(u => u.Email.ToLower() == model.EmailId.ToLower() && u.IsActive == true && u.IsDeleted == false);
                Users UserValidMobileNum = _ObjDBContext.Users.FirstOrDefault(u => u.MobilePhoneNumber.ToLower() == model.MobileNum.ToLower() && u.IsActive == true && u.IsDeleted == false);

                Random _random = new Random();
                string otp     = _random.Next(0, 999999).ToString("D6");

                if (UserValidEmailId != null)
                {
                    var UpdateOTPEmail = _ObjDBContext.Users.Where(s => s.Email == model.EmailId).FirstOrDefault();
                    if (UpdateOTPEmail != null)
                    {
                        UpdateOTPEmail.Otp = otp;
                        _ObjDBContext.Entry(UpdateOTPEmail).State = EntityState.Modified;
                        _ObjDBContext.SaveChanges();
                    }

                    SendEmailRequestModel SERM = new SendEmailRequestModel();
                    SERM.CustomerName      = UserValidEmailId.FirstName;
                    SERM.FileAttachmentURL = "";
                    SERM.MessageBody       = "Hi " + UserValidEmailId.FirstName + " Please Use " + otp + " as OTP for Change password!";
                    SERM.Subject           = "Squeeze Bill Forget Password";
                    SERM.ToEmailId         = UserValidEmailId.Email;
                    EmailService ES           = new EmailService();
                    string       EmailService = ES.SendEmail(SERM);
                    FPRM.Response.Message    = "Please check your Email Inbox for change password !";
                    FPRM.Response.StatusCode = 200;
                }
                else if (UserValidEmailId == null)
                {
                    FPRM.Response.Message    = model.EmailId + " Invalid";
                    FPRM.Response.StatusCode = 201;
                }
                else if (UserValidMobileNum != null)
                {
                    var UpdateOTPMobile = _ObjDBContext.Users.Where(s => s.MobilePhoneNumber == model.MobileNum).FirstOrDefault();
                    if (UpdateOTPMobile != null)
                    {
                        UpdateOTPMobile.Otp = otp;
                        _ObjDBContext.Entry(UpdateOTPMobile).State = EntityState.Modified;
                        _ObjDBContext.SaveChanges();
                    }

                    SendSMSRequestModel SSRM = new SendSMSRequestModel();
                    SSRM.CustomerName = UserValidEmailId.FirstName;
                    SSRM.MessageBody  = "Hi " + UserValidEmailId.FirstName + " Please Use " + otp + " as OTP for Change password!";
                    SSRM.ToMobileNum  = UserValidEmailId.MobilePhoneCountryCode + " " + UserValidEmailId.MobilePhoneNumber;
                    SMSService SS         = new SMSService();
                    string     SMSService = SS.SendSMS(SSRM);
                    FPRM.Response.Message    = "Please check your Mobile Message for change password !";
                    FPRM.Response.StatusCode = 200;
                }
                else if (UserValidMobileNum == null)
                {
                    FPRM.Response.Message    = model.MobileNum + " Invalid";
                    FPRM.Response.StatusCode = 201;
                }
            }
            catch (Exception ex)
            {
                _log.LogInformation("UnExpected");
                FPRM.Response.Message    = Convert.ToString(ex);
                FPRM.Response.StatusCode = 401;
            }
            return(FPRM);
        }