public void OrderPurchaseItemsByStore() { var dairy = new ArticleGroup("Dairy"); var vegetables = new ArticleGroup("Vegetables"); var tomato = new Article { Name = "Tomato", ArticleGroup = vegetables, IsInventory = false }; var milk = new Article { Name = "Milk", ArticleGroup = dairy, IsInventory = false }; var bag = new Unit("Bag"); var purchaseItem1 = new PurchaseItem(tomato, 1, bag); var purchaseItem2 = new PurchaseItem(milk, 3, bag); var shoppingOrder1 = new ShoppingOrder(vegetables, 50); var shoppingOrder2 = new ShoppingOrder(dairy, 30); var compartments = new[] { shoppingOrder1, shoppingOrder2 }; var store = new Store("London", compartments); var purchaseItems = new[] { purchaseItem1, purchaseItem2 }; var testee = new OrderPurchaseItemsByStoreAction(); var results = testee.OrderPurchaseItemsByStore(store, purchaseItems).ToList(); results.Should().HaveCount(2); results.Should().BeEquivalentTo(new [] { purchaseItem2, purchaseItem1 }); }
public ActionResult OrderDetail(ShoppingOrder model) { return(Json(new PearTableReponseData() { code = 200 }, JsonRequestBehavior.AllowGet)); }
public void DeleteCompartment(ShoppingOrder compartment) { if (_compartments.Contains(compartment)) { _compartments.Remove(compartment); } }
public void CreateShoppingOrder() { var order = 3; var ingredientGroup = new ArticleGroup("Vegetables"); var testee = new ShoppingOrder(ingredientGroup, order); testee.ArticleGroup.Should().Be(ingredientGroup); testee.Order.Should().Be(order); }
public void AddCompartment(ShoppingOrder compartment) { if (_compartments.Any(x => x.Order == compartment.Order)) { throw new InvalidOperationException($"There is already a compartment with order '{compartment.Order}'"); } else { _compartments.Add(compartment); } }
public static ShoppingOrder createShoppingOrder(ShoppingCart sc) { ShoppingOrder so = new ShoppingOrder(); so.ShoppingCart = sc.id; so.orderPrice = sc.getTotalPrice(); so.productCount = sc.count(); so.dato = DateTime.Now; sc.ShoppingOrders.Add(so); DB.ShoppingOrders.Add(so); DB.SaveChanges(); return so; }
public void AddingCompartmentWithSameOrderThrowsException() { var name = "London"; var existingCompartment = new ShoppingOrder(new ArticleGroup("Vegetables"), 30); var compartments = new Collection <ShoppingOrder> { existingCompartment }; var compartmentToAdd = new ShoppingOrder(new ArticleGroup("Vegetables"), 30); var testee = new Store(name, compartments); testee.Invoking(x => x.AddCompartment(compartmentToAdd)).Should().Throw <InvalidOperationException>(); }
public void DeleteCompartment() { var name = "London"; var existingCompartment = new ShoppingOrder(new ArticleGroup("Vegetables"), 30); var compartments = new Collection <ShoppingOrder> { existingCompartment }; var testee = new Store(name, compartments); testee.DeleteCompartment(existingCompartment); testee.Compartments.Should().BeEmpty(); }
static void Main(string[] args) { var order = new ShoppingOrder(); // Pendente order.ApprovePayment(); // Aprovado order.WaitPayment(); // Pendente order.ShipOrder(); order.RejectPayment(); // Daqui não altera mais o estado order.ApprovePayment(); order.WaitPayment(); order.ApprovePayment(); order.ShipOrder(); }
public void AddCompartment() { var name = "London"; var existingCompartment = new ShoppingOrder(new ArticleGroup("Vegetables"), 30); var compartments = new Collection <ShoppingOrder> { existingCompartment }; var compartmentToAdd = new ShoppingOrder(new ArticleGroup("Vegetables"), 40); var testee = new Store(name, compartments); testee.AddCompartment(compartmentToAdd); testee.Compartments.Should().BeEquivalentTo(new [] { existingCompartment, compartmentToAdd }); }
public ActionResult OrderEdit(ShoppingOrder model, int OrderStateId, string province, string county, string city) { if (ModelState.IsValid) { var list = new FirstManager().GetOneOrder(model.Id); new FirstManager().EditOrder( id: (int)list.Id, (int)list.UserId, list.ShoppingCodId, list.Shopping, list.CodNumber, OrderStateId, list.WayPay, list.Count, model.OrderName, model.OrderPhone, model.OrderAddress, model.Remarks, createTime: list.CreateTime, province, county, city ); return(Json(new PearTableReponseData() { code = 200 }, JsonRequestBehavior.AllowGet)); } else { return(Json(new PearTableReponseData() { code = 500 }, JsonRequestBehavior.AllowGet)); } }
public static OrderVariables AssignShoppingDetailsToOrderVariable(OrderVariables oVariables, ShoppingOrder billingDetails) { CommonModels oComm = new CommonModels(); OrderProcess oProcess = new OrderProcess(); //OrderVariables oVariables = new OrderVariables(); oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname = billingDetails.ShippingFirstName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname = billingDetails.ShippingLastName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1 = billingDetails.ShippingAddress1; oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt = billingDetails.ShippingAddress2; oVariables.ShipVars[oVariables.default_shp_id].ship_to_city = billingDetails.ShippingCity; oVariables.ShipVars[oVariables.default_shp_id].ship_to_state = billingDetails.ShippingState; oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode = billingDetails.ShippingZipCode; //commented by Manish 07-12-2016 oVariables.ShipVars[oVariables.default_shp_id].child_dob = billingDetails.ChildDOB != null ? billingDetails.ChildDOB.ToString() : ""; //oVariables.ShipVars[oVariables.default_shp_id].child_fname = billingDetails.ChildName; #region Code for Child Name Gender and DOB //================================= string chName = ""; chName = string.IsNullOrEmpty(billingDetails.ChildName) ? "" : billingDetails.ChildName.Trim(); string[] name = chName.Split(' '); int cnt = name.Count(); string fname = ""; for (int i = 0; i < name.Count() - 1; i++) { fname += name[i] + " "; } string lname = ""; if (cnt > 1) { lname = name[cnt - 1]; } if (fname.Trim().Length == 0) fname = name.Length > 0 ? name[0] : ""; if (lname.Trim().Length == 0) lname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname; //oVariables.ShipVars[oVariables.default_shp_id].child_dob = oProcess.ValidateDateTime(billingDetails.ChildDOB.ToString()); oVariables.ShipVars[oVariables.default_shp_id].child_fname = fname.Trim(); oVariables.ShipVars[oVariables.default_shp_id].child_lname = lname.Trim(); if (string.IsNullOrEmpty(billingDetails.ChildGender) || billingDetails.ChildGender == "") oVariables.ShipVars[oVariables.default_shp_id].child_gender = "0"; else oVariables.ShipVars[oVariables.default_shp_id].child_gender = billingDetails.ChildGender; //oVariables.referring_url = HttpContext.Current.Request.Url.ToString(); #endregion //================================================= //oVariables.referring_url = HttpContext.Current.Request.Url.ToString(); oVariables.ip_address = oComm.GetIPAddress(); oVariables.phone = billingDetails.ShippingPhone; oVariables.email = billingDetails.ShippingEmail; oVariables.bonus_option = false; if (billingDetails.isBonusSelected) { oVariables.bonus_option = true; } //Assigning Billing Address details to OVariable if (billingDetails.isBillingSameToShipping) { oVariables.bill_to_fname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname; oVariables.bill_to_lname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname; oVariables.bill_to_address1 = oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1; oVariables.bill_to_apt = oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt; oVariables.bill_to_city = oVariables.ShipVars[oVariables.default_shp_id].ship_to_city; oVariables.bill_to_state = oVariables.ShipVars[oVariables.default_shp_id].ship_to_state; oVariables.bill_to_zipcode = oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode; } else { oVariables.bill_to_fname = billingDetails.BillingFirstName.Trim(); oVariables.bill_to_lname = billingDetails.BillingLastName.Trim(); oVariables.bill_to_address1 = billingDetails.BillingAddress1.Trim(); oVariables.bill_to_apt = (!string.IsNullOrEmpty(billingDetails.BillingAddress2)) ? billingDetails.BillingAddress2.Trim() : ""; oVariables.bill_to_city = billingDetails.BillingCity.Trim(); oVariables.bill_to_state = billingDetails.BillingState.Trim(); oVariables.bill_to_zipcode = billingDetails.BillingZipCode.Trim(); } //Assigning Payment details to OVariable oVariables.credit_rule = "CCC"; oVariables.err = ""; if (oVariables.CCVars.Count > 0) { oVariables.CCVars[0].number = billingDetails.CreditCardNumber.Trim(); oVariables.CCVars[0].type = ""; oVariables.CCVars[0].expdate = billingDetails.CardExpiryMonth.Trim() + billingDetails.CardExpiryYear.Trim(); oVariables.CCVars[0].cvv = billingDetails.SecurityCode.Trim(); oVariables.CCVars[0].zipcode = billingDetails.BillingZipCode.Trim(); oVariables.total_amt = 0.0; oVariables.total_sah = 0.0; } else { CCProperties oCCVars = new OrderEngine.CCProperties(); oVariables.payment_type = "CC"; oCCVars.number = billingDetails.CreditCardNumber.Trim(); oCCVars.type = ""; oCCVars.expdate = billingDetails.CardExpiryMonth.Trim() + billingDetails.CardExpiryYear.Trim(); oCCVars.cvv = billingDetails.SecurityCode.Trim(); oCCVars.zipcode = (billingDetails.BillingZipCode != null && billingDetails.BillingZipCode != "") ? billingDetails.BillingZipCode.Trim() : "";// billingDetails.BillingZipCode.Trim(); oVariables.credit_rule = "CCC"; oVariables.CCVars.Add(oCCVars); oVariables.total_amt = 0.0; oVariables.total_sah = 0.0; } return oVariables; }
public static OrderVariables AssignShoppingDetailsToOrderVariable(OrderVariables oVariables, ShoppingOrder billingDetails) { CommonModels oComm = new CommonModels(); //OrderVariables oVariables = new OrderVariables(); oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname = billingDetails.ShippingFirstName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname = billingDetails.ShippingLastName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1 = billingDetails.ShippingAddress1; oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt = billingDetails.ShippingAddress2; oVariables.ShipVars[oVariables.default_shp_id].ship_to_city = billingDetails.ShippingCity; oVariables.ShipVars[oVariables.default_shp_id].ship_to_state = billingDetails.ShippingState; oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode = billingDetails.ShippingZipCode; oVariables.referring_url = HttpContext.Current.Request.Url.ToString(); oVariables.ip_address = oComm.GetIPAddress(); oVariables.phone = billingDetails.ShippingPhone; oVariables.email = billingDetails.ShippingEmail; oVariables.bonus_option = false; if (billingDetails.isBonusSelected) { oVariables.bonus_option = true; } //Assigning Billing Address details to OVariable if (billingDetails.isBillingSameToShipping) { oVariables.bill_to_fname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname; oVariables.bill_to_lname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname; oVariables.bill_to_address1 = oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1; oVariables.bill_to_apt = oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt; oVariables.bill_to_city = oVariables.ShipVars[oVariables.default_shp_id].ship_to_city; oVariables.bill_to_state = oVariables.ShipVars[oVariables.default_shp_id].ship_to_state; oVariables.bill_to_zipcode = oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode; } else { oVariables.bill_to_fname = billingDetails.BillingFirstName.Trim(); oVariables.bill_to_lname = billingDetails.BillingLastName.Trim(); oVariables.bill_to_address1 = billingDetails.BillingAddress1.Trim(); oVariables.bill_to_apt = (!string.IsNullOrEmpty(billingDetails.BillingAddress2)) ? billingDetails.BillingAddress2.Trim() : ""; oVariables.bill_to_city = billingDetails.BillingCity.Trim(); oVariables.bill_to_state = billingDetails.BillingState.Trim(); oVariables.bill_to_zipcode = billingDetails.BillingZipCode.Trim(); } //Assigning Payment details to OVariable oVariables.credit_rule = "CCC"; oVariables.err = ""; if (oVariables.CCVars.Count > 0) { oVariables.CCVars[0].number = billingDetails.CreditCardNumber.Trim(); oVariables.CCVars[0].type = ""; oVariables.CCVars[0].expdate = billingDetails.CardExpiryMonth.Trim() + billingDetails.CardExpiryYear.Trim(); oVariables.CCVars[0].cvv = billingDetails.SecurityCode.Trim(); oVariables.CCVars[0].zipcode = billingDetails.BillingZipCode.Trim(); oVariables.total_amt = 0.0; oVariables.total_sah = 0.0; } else { CCProperties oCCVars = new OrderEngine.CCProperties(); oVariables.payment_type = "CC"; oCCVars.number = billingDetails.CreditCardNumber.Trim(); oCCVars.type = ""; oCCVars.expdate = billingDetails.CardExpiryMonth.Trim() + billingDetails.CardExpiryYear.Trim(); oCCVars.cvv = billingDetails.SecurityCode.Trim(); oCCVars.zipcode = (billingDetails.BillingZipCode != null && billingDetails.BillingZipCode != "") ? billingDetails.BillingZipCode.Trim() : "";// billingDetails.BillingZipCode.Trim(); oVariables.credit_rule = "CCC"; oVariables.CCVars.Add(oCCVars); oVariables.total_amt = 0.0; oVariables.total_sah = 0.0; } return oVariables; }
public static void Initialize(EfCoreContext context) { context.Database.EnsureCreated(); var mealType1 = new MealType("Mittagessen", 20); var mealType2 = new MealType("Abendessen", 30); context.MealTypes.Add(mealType1); context.MealTypes.Add(mealType2); context.SaveChanges(); var unit1 = new Unit("Flasche"); var unit2 = new Unit("Packung"); var unit3 = new Unit("Gramm"); var unit4 = new Unit("Milliliter"); var unit5 = new Unit("Stück"); context.Units.AddRange(unit1, unit2, unit3, unit4, unit5); context.SaveChanges(); var articleGroup1 = new ArticleGroup("Wein & Spirituosen"); var articleGroup2 = new ArticleGroup("Brot"); var articleGroup3 = new ArticleGroup("Eier & gekühlte Fertigprodukte"); var articleGroup4 = new ArticleGroup("Milchprodukte"); var articleGroup5 = new ArticleGroup("Käse"); var articleGroup6 = new ArticleGroup("Fleisch & Wurst"); var articleGroup7 = new ArticleGroup("Fisch"); var articleGroup8 = new ArticleGroup("Obst & Gemüse"); var articleGroup9 = new ArticleGroup("Getränke"); var articleGroup10 = new ArticleGroup("Tiefkühlprodukte"); var articleGroup11 = new ArticleGroup("Kaffee & süße Aufstriche"); var articleGroup12 = new ArticleGroup("Cerealien & Backwaren"); var articleGroup13 = new ArticleGroup("Knabberzeugs & fremdländische Spezialitäten"); var articleGroup14 = new ArticleGroup("Pasta, Reis & Rösti"); var articleGroup15 = new ArticleGroup("Essig & Öl"); var articleGroup16 = new ArticleGroup("Gewürze"); var articleGroup17 = new ArticleGroup("Konserven"); var articleGroup18 = new ArticleGroup("Haushaltsmittel"); var articleGroup19 = new ArticleGroup("Hygieneprodukte"); context.ArticleGroups.AddRange(articleGroup1, articleGroup2, articleGroup3, articleGroup4, articleGroup5, articleGroup6, articleGroup7, articleGroup8, articleGroup9, articleGroup10, articleGroup11, articleGroup12, articleGroup13, articleGroup14, articleGroup15, articleGroup16, articleGroup17, articleGroup18, articleGroup19 ); context.SaveChanges(); // var tomato = new Article("Tomato", articleGroup1, false); // var pasta = new Article("Pasta", articleGroup2, true); // context.Articles.AddRange(tomato, pasta); // context.SaveChanges(); // var tomatoIngredient = new Ingredient(tomato, 2, piece); // var pastaIngredient = new Ingredient(pasta, 1, pack); // context.Ingredients.AddRange(tomatoIngredient, pastaIngredient); // context.SaveChanges(); // var soup = new Recipe("Soup", 2, new[] { tomatoIngredient }); // var pastaRecipe = new Recipe("Pasta", 1, new[] { pastaIngredient }); // context.Recipes.AddRange(soup, pastaRecipe); // context.SaveChanges(); // var meal1 = new Meal(DateTime.Now, mealType1, soup); // var meal2 = new Meal(DateTime.Now, mealType2, pastaRecipe); // var meal3 = new Meal(new DateTime(2020, 4, 12), mealType2, pastaRecipe); // context.Meals.AddRange(meal1, meal2, meal3); // context.SaveChanges(); var shoppingOrder1 = new ShoppingOrder(articleGroup1, 0); var shoppingOrder2 = new ShoppingOrder(articleGroup2, 5); var shoppingOrder3 = new ShoppingOrder(articleGroup3, 10); var shoppingOrder4 = new ShoppingOrder(articleGroup4, 15); var shoppingOrder5 = new ShoppingOrder(articleGroup5, 20); var shoppingOrder6 = new ShoppingOrder(articleGroup6, 25); var shoppingOrder7 = new ShoppingOrder(articleGroup7, 30); var shoppingOrder8 = new ShoppingOrder(articleGroup8, 35); var shoppingOrder9 = new ShoppingOrder(articleGroup9, 40); var shoppingOrder10 = new ShoppingOrder(articleGroup10, 45); var shoppingOrder11 = new ShoppingOrder(articleGroup11, 50); var shoppingOrder12 = new ShoppingOrder(articleGroup12, 55); var shoppingOrder13 = new ShoppingOrder(articleGroup13, 60); var shoppingOrder14 = new ShoppingOrder(articleGroup14, 65); var shoppingOrder15 = new ShoppingOrder(articleGroup15, 70); var shoppingOrder16 = new ShoppingOrder(articleGroup16, 75); var shoppingOrder17 = new ShoppingOrder(articleGroup17, 80); var shoppingOrder18 = new ShoppingOrder(articleGroup18, 85); var shoppingOrder19 = new ShoppingOrder(articleGroup19, 90); context.ShoppingOrders.AddRange(shoppingOrder1, shoppingOrder2, shoppingOrder3, shoppingOrder4, shoppingOrder5, shoppingOrder6, shoppingOrder7, shoppingOrder8, shoppingOrder9, shoppingOrder10, shoppingOrder11, shoppingOrder12, shoppingOrder13, shoppingOrder14, shoppingOrder15, shoppingOrder16, shoppingOrder17, shoppingOrder18, shoppingOrder19 ); context.SaveChanges(); context.Stores.Add(new Store("Küsnacht", new[] { shoppingOrder1, shoppingOrder2, shoppingOrder3, shoppingOrder4, shoppingOrder5, shoppingOrder6, shoppingOrder7, shoppingOrder8, shoppingOrder9, shoppingOrder10, shoppingOrder11, shoppingOrder12, shoppingOrder13, shoppingOrder14, shoppingOrder15, shoppingOrder16, shoppingOrder17, shoppingOrder18, shoppingOrder19 })); context.SaveChanges(); }
public async Task <IActionResult> PlaceOrder(CheckoutPageViewModel vm) { //Find UserId var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; //Find User Object var currentUser = await _userManager.FindByIdAsync(userId); //Find all CartItem and ready to process checkout IEnumerable <ShoppingCart> allSavedProducts = _shoppingCartData.GetAllByUser(currentUser); //Find all Product Detail by viewing cart List <Product> allSavedProduct = new List <Product>(); foreach (var item in allSavedProducts) { //Change Item.Product qty to user's intended purchase qty item.Product.Quantity = item.Qty; //add modified-Qty Product to list of products allSavedProduct.Add(item.Product); } ShoppingOrder newOrder = new ShoppingOrder(); newOrder.User = currentUser; newOrder.OrderAddress = vm.ShippingAddress; _checkoutData.SaveOrder(newOrder); foreach (var product in allSavedProduct) { OrderItem Item = new OrderItem(); Item.CurrentPrice = product.Price; Item.ProductId = product.ProductId; Item.Qty = product.Quantity; Item.ShoppingOrderId = newOrder.OrderId; //Modify Inventory of Product Qty product.Quantity -= Item.Qty; if (product.Quantity == 0) { //If user bought all stocks, change property of availiablity to false product.IsAvailiable = false; } _productData.EditQty(product); _checkoutData.SaveOrderItem(Item); } //Delete all item in shopping cart foreach (var product in allSavedProducts) { _shoppingCartData.Delete(product); } var myCharge = new StripeChargeCreateOptions(); // always set these properties int total = (int)vm.Total; myCharge.Amount = total * 100;; myCharge.Currency = "usd"; // set this if you want to myCharge.Description = "Charge it like it's hot"; myCharge.SourceTokenOrExistingSourceId = vm.StripeToken; // set this property if using a customer - this MUST be set if you are using an existing source! // (not required) set this to false if you don't want to capture the charge yet - requires you call capture later myCharge.Capture = true; var StripeKey = Environment.GetEnvironmentVariable("StripeSecretKey"); var chargeService = new StripeChargeService(StripeKey); StripeCharge stripeCharge = chargeService.Create(myCharge); return(RedirectToAction("Index", "Cart")); }
public void SaveOrder(ShoppingOrder ShoppingOrder) { ShoppingOrder.Create_Date = DateTime.Now; _context.Add(ShoppingOrder); _context.SaveChanges(); }