示例#1
0
 public PaymentViewModel(Payment payment)
 {
     Id = payment.ID;
     Name = payment.Name;
     Location = payment.Location;
     Email = payment.Email;
     Amount = payment.Amount;
     CurrencyId = payment.CurrencyID;
     BeneficiaryId = payment.BeneficiaryID;
     PaymentClassId = payment.ClassID;
     SoldBy = payment.SoldBy;
     Remarks = payment.Remarks;
 }
        // POST api/Payments
        public HttpResponseMessage PostPayment(Payment payment)
        {
            if (ModelState.IsValid)
            {
                db.Payments.Add(payment);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, payment);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = payment.ID }));
                return response;
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
示例#3
0
        public MailQueue(Payment payment)
        {
            MailMessage message = new MailMessage(
                                        "*****@*****.**",
                                        payment.Email,
                                        "[TALENTS FOR HUNGRY MINDS 2014] Ticket Notification",
                                        payment.GenerateMessageBody())
            {
                IsBodyHtml = true
            };

            From = message.From.Address;
            To = message.To[0].Address;
            Subject = message.Subject;
            Content = message.Body;
        }
示例#4
0
        public ActionResult Create(Payment payment)
        {
            if (ModelState.IsValid)
            {
                if (payment.ExecutiveID == -1) payment.ExecutiveID = null;

                Payment.Add(payment);
                return RedirectToAction("Index");
            }

            var paymentClasses = Enum.GetNames(typeof(PaymentClass)).Select(p => new { ID = (int)Enum.Parse(typeof(PaymentClass), p), Name = p }).ToList();
            var executives = Executive.GetAll();
            executives.Insert(0, new Executive() { ID = -1, Name = "[Select an executive...]" });

            ViewBag.BeneficiaryID = new SelectList(Account.GetCurrentUser().Profile.Beneficiaries, "ID", "Name", 0);
            ViewBag.CurrencyID = new SelectList(Account.GetCurrentUser().Profile.Currencies, "ID", "CurrencyCode", 0);
            ViewBag.ClassID = new SelectList(paymentClasses, "ID", "Name", 0);
            ViewBag.ExecutiveID = new SelectList(executives, "ID", "Name");

            return View(payment);
        }
示例#5
0
        private static List<Ticket> generateTickets(Payment payment)
        {
            List<Ticket> tickets = new List<Ticket>();
            int count = (((((int)((payment.Amount) * payment.Currency.ExchangeRate)) / 2000) * 55) +
                                                    ((((int)(payment.Amount * payment.Currency.ExchangeRate) % 2000) / 1000) * 25) +
                                                    (((((int)(payment.Amount * payment.Currency.ExchangeRate) % 2000) % 1000) / 500) * 12) +
                                                    ((((((int)(payment.Amount * payment.Currency.ExchangeRate) % 2000) % 1000) % 500) / 50) * 1)
                                                    );

            for (int i = 0; i < count; i++)
            {
                tickets.Add(new Ticket() { Name = payment.Name, TicketCode = string.Format("{0}{1}{2}{3}", payment.ClassID.ToString("00"), payment.BeneficiaryID.ToString("00"), payment.ID.ToString("X").PadLeft(5, '0'), i.ToString("00000")) });
            }

            return tickets;
        }
示例#6
0
 public static void ResendEmail(Payment payment)
 {
     //TODO: secure
     emailTickets(payment.Email, payment.Tickets, payment.BeneficiaryID);
 }
示例#7
0
        public static Payment Edit(Payment payment)
        {
            using (var db = ObjectProvider.CreateDB())
            {
                payment.CreatedByID = Account.GetCurrentUser().ID;

                db.Entry(payment).State = EntityState.Modified;
                db.SaveChanges();

                return payment;
            }
        }
示例#8
0
        public static Payment Add(Payment payment)
        {
            using (var db = ObjectProvider.CreateDB())
            {
                payment.CreatedByID = Account.GetCurrentUser().ID;

                db.Payments.Add(payment);
                db.SaveChanges();

                return payment;
            }
        }
        // PUT api/Payments/5
        public HttpResponseMessage PutPayment(int id, Payment payment)
        {
            if (ModelState.IsValid && id == payment.ID)
            {
                db.Entry(payment).State = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
示例#10
0
 //TODO: payment.CreatedByID = Account.GetCurrentUser().ID; before edit payment
 public void Edit(Payment payment)
 {
     _raisinsDb.Entry(payment).State = EntityState.Modified;
 }
示例#11
0
 public void Delete(Payment payment)
 {
     _raisinsDb.Payments.Remove(payment);
 }
示例#12
0
 //TODO: payment.CreatedByID = Account.GetCurrentUser().ID; before adding payment
 public void Add(Payment payment)
 {
     _raisinsDb.Payments.Add(payment);
 }
示例#13
0
        // PUT api/Payments/5
        public HttpResponseMessage PutPayment(int id, Payment payment)
        {
            if (ModelState.IsValid && id == payment.ID)
            {
                _unitOfWork.Payments.Edit(payment);

                try
                {
                    _unitOfWork.Complete();
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }