Example #1
0
        protected async Task SendMail(EmailModel emailModel)
        {
            isLoadingFinished = false;
            await Task.Delay(1);

            try
            {
                var result = MailingService.SendMessage(emailModel);

                if (result)
                {
                    await MatDialogService.AlertAsync("The message sent.");
                }
            }
            catch (Exception e)
            {
                Logger.LogError(e, $"{GetUserName()}*Error: Zugangsdaten/SendMail");
                ErrorModel.IsOpen       = true;
                ErrorModel.ErrorContext = e.StackTrace;
                ErrorModel.ErrorMessage = e.Message;
                IsFailed = true;
                StateHasChanged();
            }
            finally
            {
                isLoadingFinished = true;
                StateHasChanged();
            }
        }
        public ActionResult SubmitPaymentRequest(string request)
        {
            var userId = User.Identity.GetUserId();

            if (userId == null)
            {
                return(RedirectToAction("Login", "Account", new { returnUrl = Request.Url.ToString() }));
            }

            var lndClient = new LndRpcClient(
                host: System.Configuration.ConfigurationManager.AppSettings["LnMainnetHost"],
                macaroonAdmin: System.Configuration.ConfigurationManager.AppSettings["LnMainnetMacaroonAdmin"],
                macaroonRead: System.Configuration.ConfigurationManager.AppSettings["LnMainnetMacaroonRead"],
                macaroonInvoice: System.Configuration.ConfigurationManager.AppSettings["LnMainnetMacaroonInvoice"]);

            string ip = GetClientIpAddress(Request);

            try
            {
                var paymentResult = paymentsService.TryWithdrawal(request, userId, ip, lndClient);
                return(Json(paymentResult));
            }
            catch (Exception e)
            {
                MailingService.Send(new UserEmailModel()
                {
                    Destination = "*****@*****.**",
                    Body        = " Exception: " + e.Message + "\r\n Stack: " + e.StackTrace + "\r\n invoice: " + request + "\r\n user: "******"",
                    Name        = "zapread.com Exception",
                    Subject     = "User withdraw error",
                });
                return(Json(new { Result = "Error processing request." }));
            }
        }
        private ConfigurationServiceResponse ValidateBulkEmails(Guid campaignId, UserConnection userConnection)
        {
            List <Guid>    identifiers    = GetBulkEmailIdentifiers(campaignId, userConnection);
            MailingService mailingService = GetMailingService(userConnection);

            return(mailingService.ValidateMessages(identifiers.ToArray()));
        }
        public async Task <JsonResult> SendMessage(int id, string content)
        {
            var userId = User.Identity.GetUserId();

            if (userId != null)
            {
                using (var db = new ZapContext())
                {
                    var sender = db.Users
                                 .Where(u => u.AppId == userId).FirstOrDefault();

                    var receiver = db.Users
                                   .Include("Messages")
                                   .Where(u => u.Id == id).FirstOrDefault();

                    if (sender == null)
                    {
                        return(Json(new { Result = "Failure" }));
                    }

                    var msg = new UserMessage()
                    {
                        Content   = content,
                        From      = sender,
                        To        = receiver,
                        IsDeleted = false,
                        IsRead    = false,
                        TimeStamp = DateTime.UtcNow,
                        Title     = "Private message from <a href='" + @Url.Action(actionName: "Index", controllerName: "User", routeValues: new { username = sender.Name }) + "'>" + sender.Name + "</a>",//" + sender.Name,
                    };

                    receiver.Messages.Add(msg);
                    await db.SaveChangesAsync();

                    // Send email
                    if (receiver.Settings == null)
                    {
                        receiver.Settings = new UserSettings();
                    }

                    if (receiver.Settings.NotifyOnPrivateMessage)
                    {
                        string mentionedEmail = UserManager.FindById(receiver.AppId).Email;
                        MailingService.Send(user: "******",
                                            message: new UserEmailModel()
                        {
                            Subject     = "New private message",
                            Body        = "From: " + sender.Name + "<br/> " + content + "<br/><br/><a href='http://www.zapread.com'>zapread.com</a>",
                            Destination = mentionedEmail,
                            Email       = "",
                            Name        = "ZapRead.com Notify"
                        });
                    }

                    return(Json(new { Result = "Success" }));
                }
            }

            return(Json(new { Result = "Failure" }));
        }
Example #5
0
 public Handler(AppDbContext context, PersonManager personManager, CourseManager courseManager, MailingService mailingService)
 {
     _context        = context;
     _personManager  = personManager;
     _courseManager  = courseManager;
     _mailingService = mailingService;
 }
        public virtual void SendMailing()
        {
            MailingService mailingService = new MailingService(UserConnection);
            var            isDelayedStart = true;

            mailingService.SendMessage(new Guid(BulkEmailId), isDelayedStart, ApplicationUrl);
        }
Example #7
0
        public async Task <IActionResult> Register([FromBody] UserRegistrationInfo userDto,
                                                   CancellationToken cancellationToken)
        {
            try
            {
                var user = userService.CreateUser(userDto);
                await userService.ValidateUserAsync(user);

                await userService.AddUserAsync(user, userDto.Password, cancellationToken);

                var resultUser = new View.UserRegistredInfo
                {
                    Id       = user.Id,
                    Username = user.Login
                };

                MailingService emailService = new MailingService();
                await emailService.SendEmailAsync(userDto.EmailAdress,
                                                  "Успешная регистрация", "Поздравляем, " + user.Login + ", вы зарегистрировались и можете зайти в профиль на https://pr42.ru/login ! \n P.S. Подтверждения почты пока нет, но скоро будет! \n С уважением, администрация pr42.ru");

                Console.WriteLine("Email to {0} was sent", userDto.EmailAdress);
                return(Ok(resultUser));
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Example #8
0
        public ActionResult RecupAccount(RecupAccountModel model)
        {
            // On vérifie que les deux champs sont remplis
            if (ModelState.IsValid)
            {
                using (UsersContext context = new UsersContext())
                {
                    // Si on trouve un compte qui match avec les infos entrées par l'utilisateur...
                    if (context.UserProfiles.Any(
                            u => u.UserName.Equals(model.UserName, StringComparison.OrdinalIgnoreCase) &&
                            u.Email.Equals(model.Email, StringComparison.OrdinalIgnoreCase)))
                    {
                        // On crée un token permettant de réinitialiser le mot de passe ...
                        string token = WebSecurity.GeneratePasswordResetToken(model.UserName, 5);

                        // ... et on l'envoit à l'utilisateur par email
                        MailingService mailingService = new MailingService();
                        mailingService.SendTokenByEmail(token, model.Email, model.UserName);

                        return(View("RecupAccountConfirmed"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Username or password are wrong.");
                    }
                }
            }
            return(View(model));
        }
Example #9
0
 public void Initialize()
 {
     email = new Mail {
         Email = "*****@*****.**"
     };
     mockMailingRepository = new Mock <IMailingRepository>();
     sut = new MailingService(mockMailingRepository.Object);
 }
Example #10
0
        public void TestUserMentionedInCommentEmailGeneration()
        {
            MailingService mailingService = new MailingService();

            var emailHTML = mailingService.GenerateUserMentionedInCommentHTML(2);

            Assert.IsTrue(!string.IsNullOrEmpty(emailHTML));
        }
Example #11
0
        public void TestUserAliasUpdatedEmailGeneration()
        {
            MailingService mailingService = new MailingService();

            var emailHTML = mailingService.GenerateUpdatedUserAliasHTML(0, "olduser", "newuser");

            Assert.IsTrue(!string.IsNullOrEmpty(emailHTML));
        }
Example #12
0
        public void TestNewChatEmailGeneration()
        {
            MailingService mailingService = new MailingService();

            var emailHTML = mailingService.GenerateNewChatHTML(2);

            Assert.IsTrue(!string.IsNullOrEmpty(emailHTML));
        }
Example #13
0
        public void TestNewUserFollowingEmailGeneration()
        {
            MailingService mailingService = new MailingService();

            var emailHTML = mailingService.GenerateMailNewUserFollowing(1);

            Assert.IsTrue(!string.IsNullOrEmpty(emailHTML));
        }
Example #14
0
        public void TestPostCommentReplyEmailGeneration()
        {
            MailingService mailingService = new MailingService();

            var emailHTML = mailingService.GenerateMailPostCommentReplyHTML(80);

            Assert.IsTrue(!string.IsNullOrEmpty(emailHTML));
        }
        public void Initialize()
        {
            this.configuration = Substitute.For <IConfiguration>();
            this.restService   = Substitute.For <IRestService>();

            this.configuration.GetValue <string>(Arg.Any <string>()).Returns(mailingServiceUrl);

            this.cut = new MailingService(this.configuration, this.restService);
        }
Example #16
0
        public DaDMainForm()
        {
            InitializeComponent();

            _orderingService = new OrderingService();
            _mailingService  = new MailingService();

            NewOrder();
        }
Example #17
0
        public HomeController(EmployeeDataContext db, IOptions <SmtpConfig> SmtpConfig, ILogger <HomeController> logger = null)
        {
            _db     = db;
            mailing = new MailingService(SmtpConfig);

            if (logger != null)
            {
                _logger = logger;
            }
        }
Example #18
0
        internal static IMailingService GetMailingService()
        {
            string from     = ConfigurationManager.AppSettings["mailFrom"];
            string password = ConfigurationManager.AppSettings["mailPass"];
            string host     = ConfigurationManager.AppSettings["mailHost"];

            IMailingService mailingService = new MailingService(from, password, host);

            mailingService.IgnoreQueue();
            return(mailingService);
        }
Example #19
0
 public void Setup()
 {
     // перед запуском тестов
     var(mockMRepository, mockCeRepository, mockTRepository, dataBase) = GetMock();
     _mRepository  = mockMRepository;
     _ceRepository = mockCeRepository;
     _tRepository  = mockTRepository;
     _mailingsDb   = dataBase;
     _service      = new MailingService(_mRepository.Object, _ceRepository.Object, _tRepository.Object);
     _incorrectId.Add(1);
     _incorrectId.Add(10);
 }
Example #20
0
        public void TestMailWeeklySummaryEmailGeneration()
        {
            MailingService mailingService = new MailingService();

            using (var db = new ZapContext())
            {
                var userAppId = db.Users.First().AppId;

                var emailHTML = mailingService.GenerateMailWeeklySummary(userAppId);

                Assert.IsTrue(!string.IsNullOrEmpty(emailHTML));
            }
        }
Example #21
0
        public ActionResult SendMail(UserEmailModel model)
        {
            if (!ModelState.IsValid)
            {
                //TODO: Have a proper error screen
                return(RedirectToAction("Index"));
            }

            model.Destination = "*****@*****.**";
            MailingService.Send(model);

            return(RedirectToAction("FeedbackSuccess"));
        }
Example #22
0
        public ActionResult GetSpendingSum(string days)
        {
            double amount      = 0.0;
            int    numDays     = Convert.ToInt32(days);
            double totalAmount = 0.0;
            string userId      = "?";

            try
            {
                // Get the logged in user ID
                userId = User.Identity.GetUserId();

                using (var db = new ZapContext())
                {
                    var userTxns = db.Users
                                   .Include(i => i.SpendingEvents)
                                   .Where(u => u.AppId == userId)
                                   .SelectMany(u => u.SpendingEvents);

                    // need to ensure that tx.Amount is not null
                    var sum = userTxns
                              .Where(tx => DbFunctions.DiffDays(tx.TimeStamp, DateTime.Now) <= numDays) // Filter for time
                              .Sum(tx => (double?)tx.Amount) ?? 0;

                    totalAmount = userTxns
                                  .Sum(tx => (double?)tx.Amount) ?? 0;

                    amount = sum;
                }
            }
            catch (Exception e)
            {
                MailingService.Send(new UserEmailModel()
                {
                    Destination = "*****@*****.**",
                    Body        = " Exception: " + e.Message + "\r\n Stack: " + e.StackTrace + "\r\n method: GetSpendingSum" + "\r\n user: "******"",
                    Name        = "zapread.com Exception",
                    Subject     = "Account Controller error",
                });

                // If we have an exception, it is possible a user is trying to abuse the system.  Return 0 to be uninformative.
                amount = 0.0;
            }

            string value = amount.ToString("0.##");
            string total = totalAmount.ToString("0.##");

            return(Json(new { value, total }, JsonRequestBehavior.AllowGet));
        }
        public FilesController(
            EmployeeDataContext db,
            IOptions <SmtpConfig> SmtpConfig,
            FilesLibrary filesLibrary,
            ILogger <FilesController> logger = null)
        {
            mailing       = new MailingService(SmtpConfig);
            _filesLibrary = filesLibrary;

            if (logger != null)
            {
                _logger = logger;
            }
        }
        private static void Receive()
        {
            HostingEnvironment hostingEnvironment = new HostingEnvironment();

            hostingEnvironment.EnvironmentName = "production";

            MailingService service = new MailingService(new AmazonSimpleSystemsManagementClient(), hostingEnvironment);

            System.Console.WriteLine("Created the service client");

            var result = service.GetForOrderAsync(77035).Result;

            System.Console.WriteLine($"Total {result.Count} lines received");

            return;
        }
Example #25
0
        /// <summary>
        /// Send out email message
        /// </summary>
        /// <param name="message">Message contents</param>
        /// <returns>void</returns>
        public async Task SendAsync(IdentityMessage message)
        {
            if (message == null)
            {
                return;
            }

            await MailingService.SendAsync(user : "******", useSSL : true,
                                           message : new UserEmailModel()
            {
                Destination = message.Destination,
                Body        = message.Body,
                Email       = "",
                Name        = "zapread.com",
                Subject     = message.Subject,
            }).ConfigureAwait(true);
        }
Example #26
0
        public ActionResult SendFeedback(string msg, string loc)
        {
            String uid = "";

            uid = User.Identity.GetUserId();

            UserEmailModel message = new UserEmailModel();

            message.Email       = "";
            message.Name        = "ZapRead Feedback";
            message.Subject     = "ZapRead Feedback";
            message.Body        = msg + Environment.NewLine + " Location: " + loc + Environment.NewLine + Environment.NewLine + " User: "******"*****@*****.**";
            MailingService.Send(message);

            return(Json(new { result = "success" }));
        }
        private static void Dump()
        {
            var records = ParseCSV();

            System.Console.WriteLine("Parse the csv file\n");

            HostingEnvironment hostingEnvironment = new HostingEnvironment();

            hostingEnvironment.EnvironmentName = "production";

            MailingService service = new MailingService(new AmazonSimpleSystemsManagementClient(), hostingEnvironment);

            System.Console.WriteLine("Created the service client\n");

            //service.AddAsync(records).Wait();
            System.Console.WriteLine("Called the MailingService\n");
        }
Example #28
0
 protected async Task SendTestEmail()
 {
     try
     {
         MailingService.SendTestMail(string.IsNullOrWhiteSpace(ToEmail) ? GetUserName() : ToEmail, GetUserName());
         ToEmail = string.Empty;
         StateHasChanged();
     }
     catch (Exception e)
     {
         Logger.LogError(e, $"{GetUserName()}*Error: SystemErrorLogPage/SendTestEmail");
         ErrorModel.IsOpen       = true;
         ErrorModel.ErrorContext = e.StackTrace;
         ErrorModel.ErrorMessage = e.Message;
         IsFailed = true;
         StateHasChanged();
     }
 }
Example #29
0
        //POST : /api/AppUsers/Register
        public async Task <Object> PostApplicationUser(TOAppUser model)
        {
            var user = await _userManager.FindByEmailAsync(model.Email);

            if (user != null)
            {
                return(Ok("Email is allready taken"));
                //return StatusCode(400, "Email is already taken");
            }

            var applicationUser = new AppUser()
            {
                UserName     = model.UserName,
                Email        = model.Email,
                Name         = model.Name,
                Surname      = model.Surname,
                PhoneNumber  = model.PhoneNumber,
                City         = model.City,
                Company      = model.Company,
                IsFirstLogIn = true
            };

            try
            {
                var result = await _userManager.CreateAsync(applicationUser, model.Password);

                if (result.Succeeded)
                {
                    await _userManager.AddToRoleAsync(applicationUser, model.Role);

                    string token = await _userManager.GenerateEmailConfirmationTokenAsync(applicationUser);

                    MailingService.SendEmailVerification(applicationUser, model.Role, token, model.Password);
                }

                return(Ok(result));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Example #30
0
        /* Monetary aspects */

        public async Task <JsonResult> UserBalance()
        {
            string userId = "?";

            try
            {
                userId = User.Identity.GetUserId();

                if (userId == null)
                {
                    return(Json(new { balance = 0 }));
                }

                using (var db = new ZapContext())
                {
                    await EnsureUserExists(userId, db);

                    var user = db.Users
                               .Include(usr => usr.Funds)
                               .FirstOrDefault(u => u.AppId == userId);

                    return(Json(new { balance = Math.Floor(user.Funds.Balance) }));
                }
            }
            catch (Exception e)
            {
                MailingService.Send(new UserEmailModel()
                {
                    Destination = "*****@*****.**",
                    Body        = " Exception: " + e.Message + "\r\n Stack: " + e.StackTrace + "\r\n method: UserBalance" + "\r\n user: "******"",
                    Name        = "zapread.com Exception",
                    Subject     = "Account Controller error",
                });

                return(Json(new { balance = 0 }));
            }
        }