Esempio n. 1
0
        /// <summary>
        /// Sends the payment reminder.
        /// </summary>
        /// <param name="reminder">The reminder.</param>
        public void SendPaymentReminder(PaymentReminder reminder)
        {
            var configuration = _mailConfiguration.GetConfiguration();

            if (configuration.MailingEnabled)
            {
                try
                {
                    var templateConfiguration = configuration.Templates.First(t => t.Type == MemberEmailType.PaymentReminderEmail.ToString());
                    var html    = Razor.Run(MemberEmailType.PaymentReminderEmail.ToString(), reminder);
                    var subject = templateConfiguration.Subject;
                    var from    = configuration.DefaultMailingAddress;
                    var to      = reminder.Member.EmailAddress;

                    var message = new MailMessage(from, to, subject, html)
                    {
                        IsBodyHtml = true
                    };
                    message = ReplaceMemberValueTokens(message, reminder.Member);
                    SendMail(message);
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message, ex);
                }
            }
        }
Esempio n. 2
0
        public IHttpActionResult PutPaymentReminder(int id, PaymentReminder paymentReminder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != paymentReminder.ID)
            {
                return(BadRequest());
            }

            db.Entry(paymentReminder).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PaymentReminderExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private static XDocument GetPaymentReminder(System.Globalization.CultureInfo info)
        {
            List <Item> items = new List <Item>();
            Item        item  = new Item {
                Category = "furniture", Description = "bed", Id = 1, Name = "bed 12"
            };

            items.Add(item);
            Invoice invoice = new Invoice {
                Amount = 999, DueDate = DateTime.Now, InvoiceDate = Convert.ToDateTime(DateTime.Now.ToString("d", info)), InvoiceNumber = "12121sds", item = items
            };
            PaymentReminder reminder = new PaymentReminder {
                CreatedOn = DateTime.Now, Username = "******", PaymentReminderId = 123, invoice = invoice
            };

            return(new XDocument(
                       new XDeclaration("1.0", "utf-8", "yes"),
                       new XElement("PaymentReminder",
                                    new XAttribute(XNamespace.Xmlns + "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
                                    new XAttribute(XNamespace.Xmlns + "xsd", "http://www.w3.org/2001/XMLSchema"),
                                    new XElement("invoice",
                                                 new XElement("InvoiceDate", reminder.invoice.InvoiceDate),
                                                 new XElement("InvoiceNumber", reminder.invoice.InvoiceNumber),
                                                 new XElement("Amount", reminder.invoice.Amount)
                                                 ),
                                    new XElement("Username", reminder.Username)
                                    )
                       ));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PaymentReminderId,ReminderTypeId,ProductId,ExpenseId,StartDate,StartTime,EndDate,EndTime,CreatedDate,StatusPaymentReminder")] PaymentReminder paymentReminder)
        {
            if (id != paymentReminder.PaymentReminderId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(paymentReminder);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PaymentReminderExists(paymentReminder.PaymentReminderId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExpenseId"]      = new SelectList(_context.Expense, "ExpenseId", "Description", paymentReminder.ExpenseId);
            ViewData["ProductId"]      = new SelectList(_context.Product, "ProductId", "Alias", paymentReminder.ProductId);
            ViewData["ReminderTypeId"] = new SelectList(_context.ReminderType, "ReminderTypeId", "Description", paymentReminder.ReminderTypeId);
            return(View(paymentReminder));
        }
Esempio n. 5
0
        public IHttpActionResult GetPaymentReminder(int id)
        {
            PaymentReminder paymentReminder = db.PaymentReminders.Find(id);

            if (paymentReminder == null)
            {
                return(NotFound());
            }

            return(Ok(paymentReminder));
        }
Esempio n. 6
0
        public IHttpActionResult PostPaymentReminder(PaymentReminder paymentReminder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.PaymentReminders.Add(paymentReminder);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = paymentReminder.ID }, paymentReminder));
        }
        // GET: PaymentReminders/Create
        public IActionResult Create()
        {
            PaymentReminder paymentReminder = new PaymentReminder();

            paymentReminder.StartDate = DateTime.Today;
            //paymentReminder.StartTime =
            paymentReminder.EndDate = DateTime.Today.AddDays(1);

            ViewData["ExpenseId"]      = new SelectList(_context.Expense, "ExpenseId", "Description");
            ViewData["ProductId"]      = new SelectList(_context.Product, "ProductId", "Alias");
            ViewData["ReminderTypeId"] = new SelectList(_context.ReminderType, "ReminderTypeId", "Description");
            return(View(paymentReminder));
        }
Esempio n. 8
0
        public IHttpActionResult DeletePaymentReminder(int id)
        {
            PaymentReminder paymentReminder = db.PaymentReminders.Find(id);

            if (paymentReminder == null)
            {
                return(NotFound());
            }

            db.PaymentReminders.Remove(paymentReminder);
            db.SaveChanges();

            return(Ok(paymentReminder));
        }
        public async Task <IActionResult> Create([Bind("PaymentReminderId,ReminderTypeId,ProductId,ExpenseId,StartDate,StartTime,EndDate,EndTime,StatusPaymentReminder")] PaymentReminder paymentReminder)
        {
            if (ModelState.IsValid)
            {
                paymentReminder.CreatedDate           = DateTime.Today;
                paymentReminder.StatusPaymentReminder = Models.Enum.StatusPaymentReminder.Activo;
                _context.Add(paymentReminder);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ExpenseId"]      = new SelectList(_context.Expense, "ExpenseId", "Description", paymentReminder.ExpenseId);
            ViewData["ProductId"]      = new SelectList(_context.Product, "ProductId", "Alias", paymentReminder.ProductId);
            ViewData["ReminderTypeId"] = new SelectList(_context.ReminderType, "ReminderTypeId", "Description", paymentReminder.ReminderTypeId);
            return(View(paymentReminder));
        }