public async Task SendEmailToInitiatingStaffAsync(purch_requisitionnote prn)
        {
            EmailMessageObj em = new EmailMessageObj {
                ToAddresses = new List <EmailAddressObj>()
            };

            var staffList = await _serverRequest.GetAllStaffAsync();

            if (staffList.Count() > 0)
            {
                var intiatingStaff = staffList.FirstOrDefault(r => r.staffId == prn.StaffId);
                if (intiatingStaff != null)
                {
                    //var path = $"#/main/lpos";

                    //var path2 = $"{_uRIs.SelfClient}/{path}";
                    em.Subject       = "PRN APPROVED";
                    em.Content       = $"The Request for {prn.Description} has been approved ";
                    em.FromAddresses = new List <EmailAddressObj>();
                    var to = new EmailAddressObj {
                        Address = intiatingStaff.Email, Name = intiatingStaff.firstName
                    };
                    em.ToAddresses.Add(to);
                    em.SendIt   = true;
                    em.SaveIt   = false;
                    em.Template = (int)EmailTemplate.Advert;

                    await _serverRequest.SendMessageAsync(em);
                }
            }
        }
Пример #2
0
        private async Task SendMailToNewSuppliersAsync(ApplicationUser user)
        {
            var em = new EmailMessageObj {
                FromAddresses = new List <EmailAddressObj>(), ToAddresses = new List <EmailAddressObj>()
            };
            var ema = new EmailAddressObj
            {
                Address = user.Email,
                Name    = user.UserName
            };
            var path2 = $"{_uRIs.SelfClient}/#/auth/login";

            em.ToAddresses.Add(ema);
            em.Subject = "Supplier Account Created";
            em.Content = $"<p style='float:left'> Dear {user.FullName} <br> " +
                         $"Congratulations, your account has been successfully created <br> " +
                         $"Below is your profile login details<br>" +
                         $"<b>Username</b>: {user.Email} <br>" +
                         $"<b>Password</b>: Password@1 <br>" +
                         $"Please click <a href='{path2}'> here </a>  to access your profile and to complete registration</p>";

            em.SendIt   = true;
            em.SaveIt   = false;
            em.Template = (int)EmailTemplate.LoginDetails;

            await _serverRequest.SendMessageAsync(em);
        }
            public async Task SendEmailToOfficerForPaymentAsync(cor_paymentterms phase, purch_plpo lpo)
            {
                var userid = _accessor.HttpContext.User?.FindFirst(q => q.Type == "userId")?.Value;
                var user   = await _userManager.FindByIdAsync(userid);

                if (user != null)
                {
                    EmailMessageObj em = new EmailMessageObj {
                        ToAddresses = new List <EmailAddressObj>(), FromAddresses = new List <EmailAddressObj>()
                    };

                    var supplier = _dataContext.cor_supplier.FirstOrDefault(q => q.Email == user.Email);
                    var path     = $"#/purchases-and-supplier/lpo?id={phase.LPOId}";

                    var path2 = $"{_uRIs.MainClient}/{path}";


                    em.Subject = $"Payment Request";
                    em.Content = $"Supplier with supplier number {supplier.SupplierNumber} <br> is requesting for payment for " +
                                 $"the supply of {lpo.Description} <br> on  Phase '{phase.Phase}'" +
                                 $" with project status of '{ Convert.ToString((JobProgressStatus)phase.Status)} '" +
                                 $"<br> Please click <a href='{path2}'> here </a> to see details of Payment";

                    var frm = new EmailAddressObj
                    {
                        Address = supplier.Email,
                        Name    = supplier.Name,
                    };
                    em.FromAddresses.Add(frm);
                    em.ActivitIds = new List <int>();
                    em.ActivitIds.Add(14);
                    em.SendIt   = true;
                    em.SaveIt   = false;
                    em.Template = (int)EmailTemplate.Advert;

                    await _serverRequest.SendSpecificMessageAsync(em);
                }
            }