public ChangeTable(DAL.Order order, List <DAL.Table> tables) { InitializeComponent(); this.order = order; this.Tables = tables; this.LoadData(); }
public GroupTripOrder orderGroupTrip(GroupTrip groupTrip, PaymentType paymentType, Address orderAddress, User user) { if (!this.users.Contains(user)) { return(null); } if (groupTrip == null || orderAddress == null || user == null || !this.canOrderGroupTrip(groupTrip)) { return(null); } if (groupTrip.saveInDB() == null) { return(null); } GroupTripOrder groupTripOrder = new GroupTripOrder(paymentType, DateTime.Now, user, orderAddress, ++numOrders, groupTrip); DAL.Order value = groupTripOrder.saveInDB(); if (value == null) { return(null); } // value.boatToursManagerId = 1; entity.numOrders = this.numOrders; db.SaveChanges(); this.orders.Add(groupTripOrder.orderNumber, groupTripOrder); return(groupTripOrder); }
public OrderModel(DAL.Order o) { this.ID = o.ID; this.Customer_ID = o.Customer_ID; this.PizzaDetail_ID = o.PizzaDetail_ID; this.TotalPriceOrder = o.TotalPriceOrder; this.Status_ID = o.Status_ID; }
protected Order(DAL.Order order) { this.id = order.id; this.paymentType = (PaymentType)Enum.ToObject(typeof(PaymentType), order.paymentType); this.orderDate = order.orderDate ?? DateTime.Now; this.user = new User(order.User); this.billed = order.billed ?? true; //this.orderAddress = new Address(order.Address); this.price = Convert.ToDecimal(order.price); this.orderNumber = order.orderNumber ?? 0; }
public PrintBill(DAL.Order order, decimal foodPrice, decimal discount, decimal extra, decimal vat, decimal totalPrice) { InitializeComponent(); this.order = order; this.FoodPrice = foodPrice; this.Discount = discount; this.Extra = extra; this.VAT = vat; this.TotalPrice = totalPrice; this.LoadData(); }
public PaymentDialog(DAL.Order order, decimal foodPrice, decimal discount, decimal extra, decimal vat, decimal totalPrice) { InitializeComponent(); this.order = order; this.FoodPrice = foodPrice; this.Discount = discount; this.Extra = extra; this.VAT = vat; this.TotalPrice = totalPrice; this.numericUpDown1.Value = this.TotalPrice; }
public ActionResult Create(OrderModel model) { ResponseJson response = new ResponseJson(); try { if (!ModelState.IsValid) { return(Json(Globals.SetValidationError(ModelState))); } //response = Validation(response, model); //if (response.IsError) //{ // return Json(response); //} //ObjectParameter ErrorCode = new ObjectParameter("ErrorCode", 0); UpdatedInfoModel updatedInfo = new UpdatedInfoModel() { Comment = "Order Created", Type = 1, UpdatedTime = DateTime.Now, UserId = CurrentUser.Id }; string login = ""; using (AppDB db = new AppDB()) { DAL.Order order = new DAL.Order() { BuyerId = model.BuyerId, CodeNumber = "", Color = model.Color, CreatedBy = CurrentUser.Id, DeliveryDate = model.DeliveryDate, Description = model.Description, Id = Guid.NewGuid(), OrderDate = DateTime.Now, Size = model.Size, Status = 0, Style = model.Style, TotalQuantity = model.Quantity, UpdateInfo = new JavaScriptSerializer().Serialize(updatedInfo) }; db.Orders.Add(order); db.SaveChanges(); //EmailSender.SendToCHWUser(model.Email, login, login, model.Surname, "Sector Executive Officer"); } } catch (Exception ex) { response.IsError = true; response.Id = -6; } return(Json(response)); }
public BoatRentalOrder orderBoatRental(BoatRental boatRental, PaymentType paymentType, Address orderAddress, User user) { if (boatRental == null || orderAddress == null || user == null) { return(null); } if (!this.users.Contains(user)) { return(null); } bool boatFound = false; Location location = null; foreach (Location l in this.locations) { if (l.getBoats().Contains(boatRental.boat)) { boatFound = true; location = l; break; } } if (!boatFound) { return(null); } if (!location.getBoatRentals().Contains(boatRental)) { return(null); } BoatRentalOrder boatRentalOrder = new BoatRentalOrder(paymentType, DateTime.Now, user, orderAddress, ++numOrders, boatRental); DAL.Order value = boatRentalOrder.saveInDB(); if (value == null) { return(null); } //value.boatToursManagerId = 1; entity.numOrders = this.numOrders; db.SaveChanges(); this.orders.Add(boatRentalOrder.orderNumber, boatRentalOrder); return(boatRentalOrder); }
public ActionResult Create(OrderModel model) { ResponseJson response = new ResponseJson(); try { if (!ModelState.IsValid) { return Json(Globals.SetValidationError(ModelState)); } //response = Validation(response, model); //if (response.IsError) //{ // return Json(response); //} //ObjectParameter ErrorCode = new ObjectParameter("ErrorCode", 0); UpdatedInfoModel updatedInfo = new UpdatedInfoModel() { Comment = "Order Created", Type = 1, UpdatedTime = DateTime.Now, UserId = CurrentUser.Id }; string login = ""; using (AppDB db = new AppDB()) { DAL.Order order = new DAL.Order() { BuyerId = model.BuyerId, CodeNumber = "", Color = model.Color, CreatedBy = CurrentUser.Id, DeliveryDate = model.DeliveryDate, Description = model.Description, Id = Guid.NewGuid(), OrderDate = DateTime.Now, Size = model.Size, Status = 0, Style = model.Style, TotalQuantity = model.Quantity, UpdateInfo = new JavaScriptSerializer().Serialize(updatedInfo) }; db.Orders.Add(order); db.SaveChanges(); //EmailSender.SendToCHWUser(model.Email, login, login, model.Surname, "Sector Executive Officer"); } } catch (Exception ex) { response.IsError = true; response.Id = -6; } return Json(response); }
public void Post([FromBody] OrderModel model) { var transaction = ctx.Database.BeginTransaction(); try { var newOrder = new DAL.Order { Comment = model.Comment, Email = ctx.Emails.FirstOrDefault(e => e.Email1 == model.Email.Email) ?? (new DAL.Email { Email1 = model.Email.Email, Subscribe = model.Email.Subscribe }), Address = ctx.Addresses.FirstOrDefault(a => a.Street == model.Address.Street && a.PostalCode == model.Address.PostalCode) ?? (new DAL.Address { PostalCode = model.Address.PostalCode, Street = model.Address.Street }), DeliveryId = model.DeliveryMethod, PaymentId = model.PaymentMethod, StoreId = model.StoreId, IsDelivered = false, }; decimal bouquetPrice = 0; decimal totalSum = 0; foreach (var bouquet in model.Buquettes) { var tempBouquet = new DAL.Boquett { Id = bouquet.Id, Sum = bouquet.Sum, OrderId = newOrder.Id, Quantity = bouquet.Quantity }; foreach (var product in bouquet.Products) { var productTemp = ctx.Products.FirstOrDefault(p => p.Id == product.Id); bouquetPrice += productTemp.Price * product.Quantity; tempBouquet.Sum += bouquetPrice; var ProductBouquetToDAL = new DAL.ProductBoquett() // Junction table mellan product och bouqet { Boquett = tempBouquet, // Bukettens ID Product = ctx.Products.FirstOrDefault(p => p.Id == product.Id), // Produktens ID Quantity = product.Quantity, // Antalet produkter i buketten }; totalSum += bouquetPrice * bouquet.Quantity; bouquetPrice = 0; ctx.ProductBoquetts.Add(ProductBouquetToDAL); } } newOrder.TotalPrice = totalSum; ctx.Orders.Add(newOrder); ctx.SaveChanges(); transaction.Commit(); model.Id = newOrder.Id; model.Payment = ctx.PaymentMethods.Select(p => new PaymentModel { Id = p.Id, Method = p.Method }).FirstOrDefault(q => q.Id == model.PaymentMethod); model.Delivery = ctx.DeliveryMethods.Select(d => new DeliveryModel { Id = d.Id, Method = d.Method }).FirstOrDefault(q => q.Id == model.DeliveryMethod); SendEpost(model, totalSum); } catch (Exception ex) { transaction.Rollback(); } }
public ActionResult FinalisePayment(string stripeToken) { try { if (ModelState.IsValid) { var cart = Session["cart"] as CraveatsCart; //long? total = (long)order.OrderTotal; // Set your secret key: remember to change this to your live secret key in production // See your keys here: https://dashboard.stripe.com/account/apikeys StripeConfiguration.SetApiKey("sk_test_Rg2BSmdAQkVhLwSdOZyTqHGZ"); // Token is created using Checkout or Elements! // Get the payment token submitted by the form: //var token = CraveatsCart.Token; // Using ASP.NET MVC long chargeAmount = (long)(decimal.Parse(CommonUtility.DoFormat((cart.CartTotalBeforeTax + cart.CartTotalTax))) * 100); var options = new ChargeCreateOptions { Amount = chargeAmount, Currency = "cad", Description = "Order Payment 20181129", SourceId = stripeToken }; var service = new ChargeService(); Charge charge = service.Create(options); if (charge.Status == "succeeded") { DAL.Order newOrder = new DAL.Order() { DateCreated = DateTime.Now, DiscountTotal = 0.0m, OrderStatus = (int)OrderStatusEnum.Paid, OrderTotal = cart.CartTotalBeforeTax, SessionId = int.Parse(DataSecurityTripleDES.GetPlainText(SessionManager.GetContextSessionID())), TaxTotal = cart.CartTotalTax, UserId = int.Parse(DataSecurityTripleDES.GetPlainText(cart.OwnerId)) }; db.Order.Add(newOrder); db.SaveChanges(); foreach (RestaurantMenuCartDTO restaurantMenuCartDTO in cart.Items) { db.OrderDetail.Add(new OrderDetail() { IsTaxable = restaurantMenuCartDTO.IsTaxable, OrderId = newOrder.Id, ServiceId = int.Parse(DataSecurityTripleDES.GetPlainText(restaurantMenuCartDTO.Id)), ServiceOwnerId = int.Parse(DataSecurityTripleDES.GetPlainText(restaurantMenuCartDTO.ServiceOwnerId)), ServiceOwnerType = int.Parse(DataSecurityTripleDES.GetPlainText(restaurantMenuCartDTO.ServiceOwnerType)), TaxRate = restaurantMenuCartDTO.TaxRate, UnitPrice = restaurantMenuCartDTO.UnitPrice, Quantity = restaurantMenuCartDTO.Quantity, Name = restaurantMenuCartDTO.Name, Detail = restaurantMenuCartDTO.Detail }); db.SaveChanges(); } db.OrderPayment.Add(new OrderPayment() { DateProcessed = DateTime.Now, GatewayResponseCode = charge.Id, GatewayResponseVerbose = charge.Status, TotalAmount = (decimal)(charge.Amount / 100.00) }); db.SaveChanges(); cart = null; Session["cart"] = null; return(View("Success", new WebApplication.Models.ViewModel.OrderConfirmationDTO() { Id = DataSecurityTripleDES.GetEncryptedText(newOrder.Id), StatusMessage = "success" })); } else { ModelState.AddModelError("", "Unable to accept charges. Try again, and if the problem persists please review your card detail with your bank."); } } } catch (RetryLimitExceededException /* dex */) { //Log the error (uncomment dex variable name and add a line here to write a log. ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator."); } return(View()); }