コード例 #1
0
        public ActionResult PaymentOrRefund(payment _payment)
        {
            // Identify session
            long sessionID = sessionService.GetSessionID(this.HttpContext, true, false);
            long IPMEventID = sessionService.GetSessionIPMEventID(sessionID);
            long userID = sessionService.GetSessionUserID(this.HttpContext, false, false);

            // Create and insert payment
            _payment.idIPMEvent = sessionService.GetSessionIPMEventID(sessionID);
            _payment.idSession = sessionID;
            _payment.createDate = DateTime.Now;
            _payment.lastUpdate = DateTime.Now;

            payments.Insert(_payment);
            payments.Commit();
            long ID = _payment.ID;

            var _selecteditems = selecteditems.GetAll().Where(s => s.idSession == sessionID);
            foreach (selecteditem item in _selecteditems)
            {
                bool editMode = item.idReservationItem != null && item.isSiteChecked;
                bool cancelMode = item.idReservationItem != null && !item.isSiteChecked;
                bool newMode = item.idReservationItem == null && item.isSiteChecked;

                // Update existing reservation item - For edit mode
                if (cancelMode)
                {
                    var old_reservationitem = reservationitems.GetById(item.idReservationItem);
                    old_reservationitem.isCancelled = true;
                    old_reservationitem.timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
                    old_reservationitem.total = 0;
                    reservationitems.Update(old_reservationitem);
                    reservationitems.Commit();
                }
                if (editMode)
                {
                    // Create and insert reservation items
                    var _reservationitem = reservationitems.GetById(item.idReservationItem);
                    _reservationitem.idIPMEvent = item.idIPMEvent.Value;
                    _reservationitem.idRVSite = item.idRVSite.Value;
                    _reservationitem.idCustomer = item.idCustomer.Value;
                    _reservationitem.idStaff = item.idStaff.Value;
                    _reservationitem.checkInDate = item.checkInDate;
                    _reservationitem.checkOutDate = item.checkOutDate;
                    _reservationitem.site = item.site;
                    _reservationitem.siteType = item.siteType;
                    _reservationitem.weeks = item.weeks;
                    _reservationitem.weeklyRate = item.weeklyRate;
                    _reservationitem.days = item.days;
                    _reservationitem.dailyRate = item.dailyRate;
                    _reservationitem.total = item.total;
                    _reservationitem.isCancelled = false;
                    _reservationitem.lastUpdate = DateTime.Now;
                    _reservationitem.timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
                    reservationitems.Update(_reservationitem);
                    reservationitems.Commit();
                }
                if (newMode)
                {
                    // Create and insert reservation items
                    var _reservationitem = new reservationitem();
                    _reservationitem.idIPMEvent = item.idIPMEvent.Value;
                    _reservationitem.idRVSite = item.idRVSite.Value;
                    _reservationitem.idCustomer = item.idCustomer.Value;
                    _reservationitem.idStaff = item.idStaff.Value;
                    _reservationitem.checkInDate = item.checkInDate;
                    _reservationitem.checkOutDate = item.checkOutDate;
                    _reservationitem.site = item.site;
                    _reservationitem.siteType = item.siteType;
                    _reservationitem.weeks = item.weeks;
                    _reservationitem.weeklyRate = item.weeklyRate;
                    _reservationitem.days = item.days;
                    _reservationitem.dailyRate = item.dailyRate;
                    _reservationitem.total = item.total;
                    _reservationitem.isCancelled = false;
                    _reservationitem.createDate = DateTime.Now;
                    _reservationitem.lastUpdate = DateTime.Now;
                    _reservationitem.timeStamp = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss");
                    reservationitems.Insert(_reservationitem);
                    reservationitems.Commit();
                    // Create link between payment and reservation
                    var _paymentreservationitem = new paymentreservationitem();
                    _paymentreservationitem.idIPMEvent = item.idIPMEvent.Value;
                    _paymentreservationitem.idPayment = _payment.ID;
                    _paymentreservationitem.createDate = DateTime.Now;
                    _paymentreservationitem.lastUpdate = DateTime.Now;
                    _paymentreservationitem.idPayment = ID;
                    _paymentreservationitem.idReservationItem = _reservationitem.ID;
                    paymentsreservationitems.Insert(_paymentreservationitem);
                    paymentsreservationitems.Commit();
                }
            }
            // Clean selected items
            paymentService.CleanAllSelectedItems(sessionID, userID);
            paymentService.CleanOldSelectedItem(IPMEventID, userID);
            // 
            sessionService.ResetSessionCustomer(sessionID);



            return RedirectToAction("PrintPayment", new { id = ID });
        }
コード例 #2
0
        public ActionResult PaymentOrRefund(payment _payment)
        {
            // Identify session
            long sessionID = sessionService.GetSessionID(this.HttpContext);

            // Create and insert payment
            _payment.idSession = sessionID;
            _payment.createDate = DateTime.Now;
            _payment.lastUpdate = DateTime.Now;

            payments.Insert(_payment);
            payments.Commit();
            long ID = _payment.ID;

            var _selecteditems = selecteditems.GetAll().Where(s => s.idSession == sessionID);
            foreach (selecteditem item in _selecteditems)
            {
                if (item.isSiteChecked)
                {
                    // Update existing reservation item - For edit mode
                    if (item.idReservationItem != null &&
                        item.idReservationItem != IDnotFound)
                    {
                        var old_reservationitem = reservationitems.GetById(item.idReservationItem);
                        old_reservationitem.isCancelled = true;
                        old_reservationitem.total = 0;
                        reservationitems.Update(old_reservationitem);
                    }
                    // Create and insert reservation items
                    var _reservationitem = new reservationitem();
                    _reservationitem.idRVSite = item.idRVSite.Value;
                    _reservationitem.idCustomer = item.idCustomer.Value;
                    _reservationitem.idStaff = item.idStaff.Value;
                    _reservationitem.checkInDate = item.checkInDate;
                    _reservationitem.checkOutDate = item.checkOutDate;
                    _reservationitem.site = item.site;
                    _reservationitem.siteType = item.siteType;
                    _reservationitem.weeks = item.weeks;
                    _reservationitem.weeklyRate = item.weeklyRate;
                    _reservationitem.days = item.days;
                    _reservationitem.dailyRate = item.dailyRate;
                    _reservationitem.total = item.total;
                    _reservationitem.createDate = DateTime.Now;
                    _reservationitem.lastUpdate = DateTime.Now;
                    reservationitems.Insert(_reservationitem);
                    reservationitems.Commit();
                    // Create link between payment and reservation
                    // *****_reservationitem.idPayment
                    var _paymentreservationitem = new paymentreservationitem();
                    _paymentreservationitem.idPayment = _payment.ID;
                    _paymentreservationitem.idReservationItem = _reservationitem.ID;
                    _paymentreservationitem.createDate = DateTime.Now;
                    _paymentreservationitem.lastUpdate = DateTime.Now;
                    paymentsreservationitems.Insert(_paymentreservationitem);
                    paymentsreservationitems.Commit();
                }
            }

            // Clean selected items
            paymentService.CleanAllSelectedItems(sessionID);
            //
            sessionService.ResetSessionCustomer(sessionID);

            return RedirectToAction("PrintPayment", new { id = ID });
        }