public ActionResult OnPost() { if (!ModelState.IsValid) { Customers = _checkOutdbcontext.Customers.ToList(); return(Page()); } _checkOutdbcontext.Customers.Add(Customer); _checkOutdbcontext.SaveChanges(); return(Redirect("/customer")); }
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")); }
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(); } }
public void AddMerchant(Merchant merchant) { using (var contex = new CheckoutDBContext(_connectionString)) { contex.Merchant.Add(merchant); contex.SaveChanges(); } }
/// <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(); } }
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); }
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(); } }