Ejemplo n.º 1
0
        public IHttpActionResult NotifyForMissingEntries([FromBody] ProjectInvoiceModel invoices)
        {
            try
            {
                MailStorageService mailService = new MailStorageService();
                //foreach (var invoice in invoices)
                //{
                var mailBody = invoices.MailBody;

                mailService.StoreMails(new MailContent()
                {
                    ReceiverMailAddress = invoices.CustomerEmail,
                    MailBody            = mailBody,
                    MailSubject         = "Invoice for your project.",
                    DateCreated         = DateTime.Now
                });

                //}
                return(Ok("Successifully sent messages."));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult Post([FromBody] ProjectInvoiceModel invoice)
        {
            try
            {
                //    var conString = "mongodb://localhost:27017";
                //    var client = new MongoClient(conString);
                MailStorageService mailService = new MailStorageService();

                //var employee = TimeUnit.Employees.Get(x => x.Id == e.Employee.Id).FirstOrDefault();
                //var mailBody = e.MailBody(employee);
                var mailBody = invoice.MailBody;

                mailService.StoreMails(new MailContent()
                {
                    ReceiverMailAddress = invoice.CustomerEmail,
                    MailBody            = mailBody,
                    MailSubject         = "Invoices Notification",
                    DateCreated         = DateTime.Now
                });

                return(Ok("Successifully sent messages."));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public IHttpActionResult NotifyForMissingEntries([FromBody] List <MissingEntriesModel> employees)
        {
            try
            {
                MailStorageService mailService = new MailStorageService();
                foreach (var e in employees)
                {
                    //var employee = TimeUnit.Employees.Get(x => x.Id == e.Employee.Id).FirstOrDefault();
                    //var mailBody = e.MailBody(employee);
                    var mailBody = e.MailBody;

                    mailService.StoreMails(new MailContent()
                    {
                        ReceiverMailAddress = e.Employee.Email,
                        MailBody            = mailBody,
                        MailSubject         = "Missing Entries Notification",
                        DateCreated         = DateTime.Now
                    });
                }
                return(Ok("Successifully sent messages."));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }