Esempio n. 1
0
 private NotificationSMS FormatOrderSaleSms(NotificationOrderSale noti)
 {
     var sms = new NotificationSMS();
     sms.HubId = noti.DistributorId;
     sms.Recipitents = GetPhoneNumber(new List<Guid> { noti.DistributorId, noti.SalemanId, noti.OutletId });// new List<string> { "254722557538" };
     sms.SmsBody = "Order " + noti.DocumentRef + "\n"
         + "of Vat AMT=" + noti.TotalVat + ",\n"
         + "Discount  AMT=" + noti.SalevalueDiscount + ",\n"
         + "Gross AMT=" + noti.TotalGross + ",\n"
         + "and  Net AMT=" + noti.TotalNet + "\nStatus= Confirmed ";
     return sms;
 }
Esempio n. 2
0
        private MailMessage FormatOrderSale(NotificationOrderSale notification)
        {
            var distributor = _costCentreRepository.GetById(notification.DistributorId);
            var salesman = _costCentreRepository.GetById(notification.SalemanId);
            var outlet = _costCentreRepository.GetById(notification.OutletId);
            if (outlet == null || distributor == null || salesman == null)
                throw new Exception("Invalid distributor , salesman or outlet");
            var msg = new MailMessage();
            GetAddresses(distributor.Id).ForEach(msg.To.Add);
            GetAddresses(salesman.Id).ForEach(msg.To.Add);
            GetAddresses(outlet.Id).ForEach(msg.To.Add);
           // msg.To.Add("*****@*****.**");
           

            if (msg.To.Count == 0) return null;
            msg.Subject = string.Format("Order / Sale {0} Notification", notification.DocumentRef);
            msg.IsBodyHtml = true;
            string html = "<div>";
           html += "</br><table >";
           html += "<thead><tr><th>Item</th><th>Quantity</th><th>UnitPrice</th><th>VAT</th><th>Discount</th><th>Total Gross</th><th>Total Net</th></tr></thead>";
            foreach (var item in notification.Items)
            {
                html += string.Format("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td><td>{6}</td></tr>", item.ItemName, item.Quantity, item.UnitPrice, item.TotalVat, item.Discount, item.TotalGross, item.TotalNet);  
            }
            html += " </table>";
          
            string body = string.Empty;
            using (StreamReader reader = new StreamReader("service/resources/orderEmailTemplate.htm"))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Distributor}", distributor.Name);
            body = body.Replace("{Salesman}", salesman.Name);
            body = body.Replace("{Outlet}", outlet.Name);
            body = body.Replace("{SalevalueDiscount}", notification.SalevalueDiscount.ToString("N2"));
            body = body.Replace("{TotalVat}", notification.TotalVat.ToString("N2"));
            body = body.Replace("{TotalNet}", notification.TotalNet.ToString("N2"));
            body = body.Replace("{TotalGross}", notification.TotalGross.ToString("N2"));
            body = body.Replace("{DocumentRef}", notification.DocumentRef);
          
          

            body = body.Replace("{Items}", html);
            
            msg.Body = body;
            return msg;
        }
Esempio n. 3
0
        private static void TestNotification()
        {
            var notificationservice = ObjectFactory.GetInstance<IOutgoingNotificationQueueRepository>();
            var cost = ObjectFactory.GetInstance<ICostCentreRepository>().GetAll().First();
            var config = ObjectFactory.GetInstance<IConfigService>().Load();
            var data = new NotificationOrderSale();
            data.Id = Guid.NewGuid();
            data.DistributorId = config.CostCentreId;
            data.OutletId = cost.Id;
            data.SalemanId = cost.Id;
            data.Items = new List<NotificationOrderSaleItem>
                             {
                                 new NotificationOrderSaleItem {Discount = 2, ItemName = "Mango,"},
                                 new NotificationOrderSaleItem {Discount = 2, ItemName = "Banana,"}
                             };

            notificationservice.Add(data);
        }