コード例 #1
0
ファイル: Customer.cshtml.cs プロジェクト: Joeyvoy/Exercise3
 public ActionResult OnPost()
 {
     if (!ModelState.IsValid)
     {
         Customers = _checkOutdbcontext.Customers.ToList();
         return(Page());
     }
     _checkOutdbcontext.Customers.Add(Customer);
     _checkOutdbcontext.SaveChanges();
     return(Redirect("/customer"));
 }
コード例 #2
0
ファイル: Edit.cshtml.cs プロジェクト: Joeyvoy/Exercise3
        public ActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }
            Customer cust = new Customer();

            cust = _checkOutdbcontext.Customers.FirstOrDefault(customer => customer.CustomerId == Customer.CustomerId);

            if (cust != null)
            {
                //update each field based on the submitted POST values
                cust.Name         = Customer.Name;
                cust.Address      = Customer.Address;
                cust.CheckIn      = Customer.CheckIn;
                cust.CheckOut     = Customer.CheckOut;
                cust.RoomNumber   = Customer.RoomNumber;
                cust.EmailAddress = Customer.EmailAddress;
                cust.Billing      = Customer.Billing;

                //update the student
                _checkOutdbcontext.Update(cust);
                //save the changes
                _checkOutdbcontext.SaveChanges();
            }
            return(Redirect("Customer"));
        }
コード例 #3
0
 public void Post([FromBody] List <BasketHelper> customerBasket)
 {
     _context.CheckoutItem.RemoveRange(_context.CheckoutItem);
     for (int i = 0; i < customerBasket.Count(); i++)
     {
         CheckoutItem _checkoutItem = new CheckoutItem
         {
             ItemName  = customerBasket[i].ItemName,
             ItemPrice = customerBasket[i].ItemPrice,
             ItemBrand = customerBasket[i].ItemBrand,
             ItemType  = customerBasket[i].ItemType,
             Pic       = customerBasket[i].Pic,
             Quantity  = customerBasket[i].Quantity
         };
         if (_checkoutItem.Quantity > 1)
         {
             _checkoutItem.ItemPriceTotal = _checkoutItem.ItemPrice * _checkoutItem.Quantity;
         }
         else
         {
             _checkoutItem.ItemPriceTotal = _checkoutItem.ItemPrice;
         }
         decimal.Round(_checkoutItem.ItemPriceTotal, 2);
         _context.CheckoutItem.Add(_checkoutItem);
         _context.SaveChanges();
     }
 }
コード例 #4
0
 public void AddMerchant(Merchant merchant)
 {
     using (var contex = new CheckoutDBContext(_connectionString))
     {
         contex.Merchant.Add(merchant);
         contex.SaveChanges();
     }
 }
コード例 #5
0
ファイル: PaymentService.cs プロジェクト: amahdavy/Checkout
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <param name="newStatus"></param>
 public void UpdateTemporaryTransactionPaymentStatus(long id, string newStatus)
 {
     using (var contex = new CheckoutDBContext(_connectionString))
     {
         var temporaryTransaction = contex.TemporaryTransaction.Find(id);
         temporaryTransaction.PaymentStatus       = newStatus;
         temporaryTransaction.ModifyDate          = DateTime.Now;
         contex.Entry(temporaryTransaction).State = EntityState.Modified;
         contex.SaveChanges();
     }
 }
コード例 #6
0
ファイル: PaymentService.cs プロジェクト: amahdavy/Checkout
        public PaymentResponse CreatePayment(TemporaryTransaction temporaryTransaction)
        {
            using (var contex = new CheckoutDBContext(_connectionString))
            {
                contex.TemporaryTransaction.Attach(temporaryTransaction);
                contex.Entry(temporaryTransaction).State = EntityState.Added;
                contex.SaveChanges();
            }

            PaymentResponse paymentResponse = temporaryTransaction.ToPaymentResponse();

            paymentResponse.CheckoutUrl = Tools.GetCheckoutUrl(_configuration, temporaryTransaction.TransctionCode);

            return(paymentResponse);
        }
コード例 #7
0
ファイル: PaymentService.cs プロジェクト: amahdavy/Checkout
        public void AddTransaction(CardTransaction cardTransaction)
        {
            using (var contex = new CheckoutDBContext(_connectionString))
            {
                var temporaryTransaction = cardTransaction.TemporaryTransaction;
                temporaryTransaction.PaymentStatus       = PaymentStatus.Paid;
                temporaryTransaction.ModifyDate          = DateTime.Now;
                contex.Entry(temporaryTransaction).State = EntityState.Modified;
                contex.TemporaryTransaction.Update(temporaryTransaction);

                contex.CardTransaction.Attach(cardTransaction);
                contex.Entry(cardTransaction).State = EntityState.Added;
                contex.SaveChanges();
            }
        }