Exemplo n.º 1
0
        public ActionResult AcceptAppointment(int?id, int?serviceId)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Record record = db.Records.Find(id);

            record.TypeOfServiceId = serviceId;
            TypeOfService   typeOfService = db.TypeOfServices.Where(u => u.Id == serviceId).FirstOrDefault();
            ApplicationUser Patient       = db.Users.Find(User.Identity.GetUserId());
            Payment         payment       = new Payment()
            {
                RecordId  = record.Id,
                PatientId = Patient.Id,
                amount    = typeOfService.Price,
                order_id  = Guid.NewGuid().ToString()
            };

            ViewBag.Patient = Patient;
            ViewBag.Payment = payment;
            ViewBag.Record  = record;
            db.Payments.Add(payment);
            db.SaveChanges();
            return(View("Payment", LiqPayHelper.GetLiqPayModel(payment, typeOfService, Patient)));
        }
Exemplo n.º 2
0
        public ActionResult PayTheBill(string orderId)
        {
            var ord = DatAcessService.FindOrder(Convert.ToInt32(orderId));

            ord.Status = "Payed";
            DatAcessService.CreateOrder(ord);
            return(View(LiqPayHelper.GetLiqPayModel(orderId)));
        }
Exemplo n.º 3
0
        public ActionResult BuyTickets(List <SelectedSeatsViewModel> selected_seats, int?session_id)
        {
            if (!IsValidSelectedSeats(selected_seats, session_id) || !ModelState.IsValid)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            // створюю список позицій замовлення (квитків)
            Session          session    = sessionRepository.FindBy(x => x.Id == session_id).FirstOrDefault();
            List <OrderItem> orderItems = new List <OrderItem>();

            foreach (var item in selected_seats)
            {
                TicketPrice ticketPrice = session.TicketPrices.FirstOrDefault(x => x.Seat.Row == item.Row && x.Seat.Number == item.Number);
                orderItems.Add(new OrderItem
                {
                    Movie  = session.Movie,
                    Price  = ticketPrice.Price,
                    Ticket = new Ticket
                    {
                        SessionDateTime  = session.DateTime,
                        CreationDateTime = DateTime.Now,
                        TicketPrice      = ticketPrice,
                        Seat             = ticketPrice.Seat,
                        StatusId         = 3, // зарезервовано на 15хв
                    }
                });
            }

            // створюю замовлення та зберігаю його в бд
            ApplicationUserManager userMgr = new ApplicationUserManager(new UserStore <ApplicationUser>(context));
            Order order = new Order
            {
                TestIdForLiqpay = Guid.NewGuid().ToString(), // ця властивість необхідна для тестування "лікпею"
                OrderItems      = orderItems,
                OrderStatusId   = 3,                         // статус "відхилено" поки користувач не заплатить
                User            = userMgr.FindByName(User.Identity.Name),
                PurchaseDate    = DateTime.Now
            };

            orderRepository.AddOrUpdate(order);
            orderRepository.Save();
            TicketHub.NotifyToAllClients();

            // на основі створенго замовлення збираю необхідні для liqpay api дані та відправляю їх на в'ю
            LiqPayHelper liqPayHelper = new LiqPayHelper(ConfigurationManager.AppSettings["LiqPayPrivateKey"], ConfigurationManager.AppSettings["LiqPayPublicKey"]);
            string       redirect_url = Request.Url.Scheme + System.Uri.SchemeDelimiter + Request.Url.Host +
                                        (Request.Url.IsDefaultPort ? "" : ":" + Request.Url.Port) + "/Order/LiqPayCallback";
            var model = liqPayHelper.GetLiqPayModel(order, redirect_url);

            return(View(model));
        }
Exemplo n.º 4
0
        public ActionResult <IEnumerable <PatientReceptionViewModel> > GetPatientsReceptions()
        {
            var patient = Utils.GetPatient(_caller, _context);

            var result =
                from reception in _context.Receptions
                join doctor in _context.Doctors on reception.DoctorId equals doctor.DoctorId
                where reception.PatientId == patient.PatientId
                orderby reception.Date
                select new PatientReceptionViewModel
            {
                ReceptionId  = reception.ReceptionId,
                PatientId    = reception.PatientId,
                DoctorId     = reception.DoctorId,
                HospitalId   = reception.HospitalId,
                Time         = reception.Time,
                Duration     = reception.Duration,
                FormatedDate = $"{reception.Date.Day}/{reception.Date.Month}/{reception.Date.Year}",
                DayOfWeek    = reception.DayOfWeek,
                Address      = reception.Address,
                Purpose      = reception.Purpose,
                Result       = reception.Result,
                Price        = reception.Price,
                Name         = doctor.Name,
                PaymentId    = reception.PaymentId,
                IsPayed      = reception.IsPayed
            };

            var receptions = result.ToList();

            for (var i = 0; i < receptions.Count; i++)
            {
                var paymentId   = Guid.NewGuid().ToString();
                var liqPayModel = LiqPayHelper.GetLiqPayModel(paymentId, Convert.ToInt32(receptions[i].Price));
                receptions[i].Data      = liqPayModel.Data;
                receptions[i].Signature = liqPayModel.Signature;

                var receptionToUpdate = _context.Receptions.Find(receptions[i].ReceptionId);
                receptionToUpdate.PaymentId             = paymentId;
                _context.Entry(receptionToUpdate).State = EntityState.Modified;
            }

            _context.SaveChangesAsync();

            return(Ok(receptions));
        }
Exemplo n.º 5
0
 public LiqPayCheckoutFormModel GetLiqPayModel(int doctorId)
 {
     return(LiqPayHelper.GetLiqPayModel(Guid.NewGuid().ToString(), Convert.ToInt32(_context.Doctors.First(d => d.DoctorId == doctorId).ReceptionPrice)));
 }
Exemplo n.º 6
0
 // GET: Payment
 public ActionResult Index(int userId)
 {
     return View(LiqPayHelper.GetLiqPayModel(Guid.NewGuid().ToString(), userId));
 }
 public ActionResult Payment(int?amount)
 {
     return(View(LiqPayHelper.GetLiqPayModel(Guid.NewGuid().ToString(), amount.HasValue?amount.Value:100)));
 }
 public ActionResult Index()
 {
     return(View(LiqPayHelper.GetLiqPayModel(Guid.NewGuid().ToString())));
 }