public void CreateUserSubscription() { CartLogic cartlogic = new CartLogic(); if (usr != null) { var itemList = cartlogic.GetCartItems(usr.UserId); if (itemList.Count > 0) { int i = 0; foreach (var cartItem in itemList) { string userId = usr.UserId; UserSubscription subs = new UserSubscription(); subs.SubscriptionTypeId = cartItem.SubscriptionTypeId; subs.Quantity = cartItem.Quantity; subs.UserId = userId; subs.SubscriptionDate = DateTime.Now; var data = logic.CreateUserSubscription(subs, usr.OrganizationId); i++; } Assert.IsTrue(i > 0); } else { Assert.Fail("Specified User not EXist in the application"); } } else { Assert.Fail("Specified User not EXist in the application"); } }
async void getCartCountHomeOnly(App app = null) { Application.Current.Properties["cart_count"] = "0"; Application.Current.Properties["fav_count"] = "0"; try { if (Application.Current.Properties.ContainsKey("user_id")) { var response = await CartLogic.CartCount(Application.Current.Properties["user_id"].ToString()); if (response.status == 200) { Application.Current.Properties["cart_count"] = response.cart_count.ToString(); Application.Current.Properties["fav_count"] = response.fav_count.ToString(); CartCount = Application.Current.Properties["cart_count"].ToString(); FavCount = Application.Current.Properties["fav_count"].ToString(); OnPropertyChanged(nameof(CartCount)); OnPropertyChanged(nameof(FavCount)); } } } catch (Exception ex) { Config.ErrorStore("BadgesVM-getCartCountHomeOnly", ex.Message); System.Diagnostics.Debug.WriteLine(ex.Message); } }
// PUT: api/Cart/2 update public void Put(int id, [FromBody] Cart updateCart) { var cl = new CartLogic(); updateCart.Id = id; cl.UpdateCart(updateCart); }
private async void RemoveCoupon_Tapped(object sender, EventArgs e) { try { string CouponId = null; if (CheckoutPage.coupon != null) { CouponId = CheckoutPage.coupon.id.ToString(); } if (!string.IsNullOrEmpty(CouponCodeId)) { CouponId = CouponCodeId; } Config.ShowDialog(); var response = await CartLogic.RemoveCoupon(Application.Current.Properties["user_id"].ToString(), CouponId); if (response.status == 200) { Config.HideDialog(); getData(); //Config.SnackbarMessage(response.message); } else { Config.HideDialog(); //Config.ErrorSnackbarMessage(response.message); } } catch { Config.HideDialog(); } }
async void DeleteProduct(Product Item) { try { Config.ShowDialog(); Dictionary <string, int> CartItem = new Dictionary <string, int>(); CartItem.Add("cart_id", Item.id); CartItem.Add("product_id", Item.id); CartItem.Add("user_id", int.Parse(Application.Current.Properties["user_id"].ToString())); var response = await CartLogic.DeleteCartItem(CartItem); if (response.status == 200) { getData(); } else if (response.status == 220) { getData(); } else { getData(); } Config.HideDialog(); } catch (Exception ex) { Config.ErrorStore("CartPage-DeleteProduct", ex.Message); Config.HideDialog(); Config.ErrorSnackbarMessage(Config.ApiErrorMessage); } }
public bool CreateSubscriptionAddToCart(SubscriptionType type) { SubscriptionTypeLogic typeLOgic = new SubscriptionTypeLogic(); SubscriptionType subType = typeLOgic.CreateSubscriptionWithProduct(type); if (subType == null && String.IsNullOrEmpty(typeLOgic.ErrorMessage)) { ErrorMessage = typeLOgic.ErrorMessage; } else { CartItem item = new CartItem() { SubscriptionTypeId = subType.Id, DateCreated = DateTime.Now.Date, Quantity = 1, UserId = type.CreatedBy, Price = subType.Price }; CartLogic logic = new CartLogic(); var status = logic.CreateCartItem(item); if (!status) { ErrorMessage = logic.ErrorMessage; } } return(String.IsNullOrEmpty(ErrorMessage)); }
async void getData(App app = null) { try { if (Application.Current.Properties.ContainsKey("user_id")) { Config.ShowDialog(); var cartItems = await CartLogic.GetCartItems(int.Parse(Application.Current.Properties["user_id"].ToString())); if (cartItems.status == 200) { emptyContent.IsVisible = false; mainContent.IsVisible = true; ViewModel.CartItems = new ObservableCollection <Cart>(cartItems.data.cart_data); decimal total = 0; int itemQuantity = 0; foreach (var item in cartItems.data.cart_data) { total += decimal.Parse(item.total_without_tax); itemQuantity += 1; } //t_total.Text = "Rs " + total; decimal myTotal = (Convert.ToDecimal(cartItems.delivery_charges) + Convert.ToDecimal(total)); t_quantity.Text = (itemQuantity == 1) ? itemQuantity + " Item" : itemQuantity + " Items"; //t_delivery.Text = "Rs " + Convert.ToDecimal(cartItems.delivery_charges); m_total.Text = "Rs " + total; b_total.Text = "Rs " + total; TotalLimit = total; minOrderAmount = cartItems.minimum_order_amount; //t_total.Text = "Rs " + myTotal; //l_grand_total.Text = "Grand Total"; //b_quantity.Text = itemQuantity + " Items"; if (cartItems.data.cart_data.Any()) { b_cart.IsVisible = true; //header.IsVisible = true; } Config.HideDialog(); } else { EmptyCart(); } } else { EmptyCart(); } } catch (Exception ex) { Config.HideDialog(); EmptyCart(); Config.ErrorStore("CartPage-getData", ex.Message); Config.ErrorSnackbarMessage(Config.ApiErrorMessage); //await DisplayAlert("Alert", Config.ApiErrorMessage, "Ok"); } }
/// <summary> /// Add Product To Cart /// </summary> /// <param name="product"></param> /// <returns></returns> public ActionResult AddToCart(Guid product) { CartDTO cartDTO = new CartDTO(); Guid id = new Guid(product.ToString()); CartLogic.AddToCart(new Guid(Session["id"].ToString()), id); return(RedirectToAction("Cart")); }
public CartLogicTest() { cartLogic = new CartLogic(); logic = new UserLogic(); subTypeLogic = new SubscriptionTypeLogic(); InitializerClass.Initialize(); usr = logic.GetUserByEmail("*****@*****.**"); }
public ShoppingController() { this.cart_Service = new CartLogic(); this.item_Service = new ItemLogic(); this.CategoryLogic = new CategoryLogic(); this.department_Service = new CategoryLogic(); }
public OrdersPage() { InitializeComponent(); orderLogic = new OrderLogic(); statusLogic = new OrderStatusLogic(); cartLogic = new CartLogic(); }
public async Task <IActionResult> AddToCart(Game game) { var gameToAdd = _context.Game.SingleOrDefault(g => g.GameID == game.GameID); var cartToAddTo = CartLogic.GetCart(_context, HttpContext); cartToAddTo.AddToCart(gameToAdd); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public ActionResult CheckOut() { CartLogic cartTotal = new CartLogic(); CartViewModel viewModel = new CartViewModel(); viewModel.SingleFee = mapper.Map(FeesDAL.GetActiveFee()); viewModel.Cart = mapper.Map(CartDAL.GetCartItems((int)Session["UserID"])); return(View(viewModel)); }
public async void AddToCart(Product product) { try { if (Application.Current.Properties.ContainsKey("isLoggedIn")) { Config.ShowDialog(); Dictionary <string, string> addToCart = new Dictionary <string, string>(); addToCart.Add("product_id", product.id.ToString()); addToCart.Add("user_id", Application.Current.Properties["user_id"].ToString()); addToCart.Add("quantity", "1"); addToCart.Add("scheduled", "0"); //addToCart.Add("product_variation_id", product.selected_variant_id.ToString()); if (product.selected_variant_id == 0) { addToCart.Add("product_variation_id", product.get_product_variations[0].id.ToString()); } else { addToCart.Add("product_variation_id", product.selected_variant_id.ToString()); } //if (productVariation != null) addToCart.Add("product_variation_id", productVariation.id.ToString()); addToCart.Add("from_date", DateTime.Now.ToString("yyyy-MM-dd")); addToCart.Add("to_date", DateTime.Now.ToString("yyyy-MM-dd")); var response = await CartLogic.AddToCart(addToCart); if (response.status == 200) { HomeVM.MyCartCounter = response.cart_count; MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle); MessagingCenter.Send((App)Application.Current, "getCartCountHomeOnly"); Config.HideDialog(); Config.SnackbarMessage(response.message); getData(); } else { Config.HideDialog(); Config.SnackbarMessage(response.message); } } else { Config.HideDialog(); await Navigation.PushAsync(new LoginPage()); } } catch (Exception ex) { Config.ErrorStore("ProductsPage-AddToCart", ex.Message); Config.HideDialog(); Config.ErrorSnackbarMessage(Config.ApiErrorMessage); } }
public void CartManagement_EmptyCartAddAnimal_AnAnimalIsAdded() { var memoryCache = new MemoryCache(new MemoryCacheOptions()); var resultingCart = new CartLogic(memoryCache).AddAnimal("TEST_CART", 1); var animal = resultingCart.CartContents.First(); Assert.Equal("TEST_CART", resultingCart.Id); Assert.Equal(1, resultingCart.CartContents.First().Quantity); Assert.Equal(1, resultingCart.CartContents.First().Id); }
public async Task <IActionResult> EmptyCart() { var cartToEmpty = CartLogic.GetCart(_context, HttpContext); await cartToEmpty.RestoreStock(); await cartToEmpty.EmptyCart(); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(ShowCarts))); }
private async void addToCart_Tapped(object sender, EventArgs e) { try { if (Application.Current.Properties.ContainsKey("isLoggedIn")) { Config.ShowDialog(); var productVariation = _product.get_product_variations .FirstOrDefault(x => x.weightUnit == weight.Items[weight.SelectedIndex]); Dictionary <string, string> addToCart = new Dictionary <string, string>(); addToCart.Add("product_id", _product.id.ToString()); addToCart.Add("user_id", Application.Current.Properties["user_id"].ToString()); addToCart.Add("quantity", quantity.Text); addToCart.Add("scheduled", "0"); if (productVariation != null) { addToCart.Add("product_variation_id", productVariation.id.ToString()); } addToCart.Add("from_date", DateTime.Now.ToString("yyyy-MM-dd")); addToCart.Add("to_date", DateTime.Now.ToString("yyyy-MM-dd")); var response = await CartLogic.AddToCart(addToCart); if (response.status == 200) { Config.HideDialog(); Config.SnackbarMessage(response.message); HomeVM.MyCartCounter = response.cart_count; MessagingCenter.Send((App)Application.Current, "NavigationBar", _pageTitle); MessagingCenter.Send((App)Application.Current, "getCartCountHomeOnly"); CustomNavigationBarVM.MenuIcon = "back.png"; await Navigation.PushAsync(new CartPage()); //await DisplayAlert("Success", response.message, "Ok"); } else { Config.HideDialog(); Config.SnackbarMessage(response.message); } } else { Config.HideDialog(); await Navigation.PushAsync(new LoginPage()); } } catch (Exception ex) { Config.ErrorStore("ProductDetailPage-addToCart_Tapped", ex.Message); Config.HideDialog(); await DisplayAlert("Alert", Config.ApiErrorMessage, "Ok"); } }
public async Task <IActionResult> ShowCarts() { var cart = CartLogic.GetCart(_context, HttpContext); var thisCart = await cart.GetCartItems(); if (!thisCart.Any()) { return(RedirectToAction(nameof(SendBackToStore))); } return(View(thisCart)); }
public async Task <IActionResult> DeleteConfirmed(int id) { var cart = CartLogic.GetCart(_context, HttpContext); await cart.RemoveFromCartAsync(id); await _context.SaveChangesAsync(); await cart.SetCartTotal(); return(RedirectToAction(nameof(ShowCarts))); }
/// <summary> /// Cart Summary Function /// </summary> /// <returns></returns> public ActionResult Cart() { if (Session["id"] == null) { return(HttpNotFound()); } string id = Session["id"].ToString(); CartDTO cart = CartLogic.CustomerCart(new Guid(id)); Cart cartView = CartMapping.MapCart(cart); return(View(cartView)); }
private async void Button_Clicked(object sender, EventArgs e) { try { Config.ShowDialog(); Dictionary <string, string> valuePairs = new Dictionary <string, string>(); valuePairs.Add("order_delivery_id", Item.id.ToString()); valuePairs.Add("date", rescheduleDatePicker.Date.ToString()); valuePairs.Add("cart_id", Item.cart_id.ToString()); var response = await CartLogic.RescheduleOrderItem(valuePairs); if (response.status == 200) { Config.HideDialog(); OrderDetailPage.ViewModel.OrderDetailList = new ObservableCollection <OrderDetail>(response.data.ToList()); await PopupNavigation.Instance.PopAsync(); } else { Config.HideDialog(); Config.SnackbarMessage(response.message); } //var item = reasonsList.SelectedItem as Reason; //var response = await DeliveryStatus.UpdateDeliveryStatus(_OrderDeliveryId.ToString(), "FL", item.id.ToString()); //if (response.status == 200) //{ // Config.HideDialog(); // Config.SnackbarMessage(response.message); // CurrentOrderDetailPage.ViewModel.CurrentOrderDetailList.Remove(CurrentOrderDetailPage.ViewModel.CurrentOrderDetailList.Where(a => a.order_delivery_id == _OrderDeliveryId).Single()); // if (CurrentOrderDetailPage.ViewModel.CurrentOrderDetailList.Count == 0) // { // await PopupNavigation.Instance.PopAsync(true); // Application.Current.MainPage = new MasterTemplate(); // } // else // { // await PopupNavigation.Instance.PopAsync(true); // } //} //else //{ // Config.HideDialog(); // Config.SnackbarMessage(response.message); //} } catch (Exception ex) { Config.ErrorStore("ReSchedulePopup-Button_Clicked", ex.Message); Config.HideDialog(); Config.ErrorSnackbarMessage(Config.ApiErrorMessage); } }
public async Task <IActionResult> AddToCart(int id) { var gameToAdd = _context.Game.SingleOrDefault(g => g.ID == id); var cartToAddTo = CartLogic.GetCart(_context, HttpContext); await cartToAddTo.AddToCart(gameToAdd); await _context.SaveChangesAsync(); await cartToAddTo.SetCartTotal(); return(RedirectToAction(nameof(ShowCarts))); }
public PurchaseOrder OfflinePayment(string userId) { CartLogic cartLogic = new CartLogic(); PurchaseOrderLogic orderLogic = new PurchaseOrderLogic(); PurchaseOrder order = new PurchaseOrder(); try { var items = cartLogic.GetCartItems(userId); if (items.Count == 0) { return(null); } order.UserId = userId; order.CreatedDate = DateTime.Now.Date; order.PurchaseOrderNo = orderLogic.CreatePONumber(); List <PurchaseOrderItem> poItemList = new List <PurchaseOrderItem>(); var total = 0.0; foreach (var item in items) { PurchaseOrderItem poItem = new PurchaseOrderItem() { Quantity = item.Quantity, SubscriptionId = item.SubscriptionTypeId }; poItemList.Add(poItem); total += item.Price; } order.Total = total; var obj = orderLogic.CreatePurchaseOrder(order); if (obj != null && poItemList.Count > 0) { POItemLogic itemLogic = new POItemLogic(); itemLogic.CreateItem(poItemList, obj.Id); foreach (var item in items) { item.IsPurchased = true; cartLogic.UpdateCartItem(item); } } return(obj); } catch (Exception ex) { ErrorMessage = ex.Message; } return(null); }
public async Task <IActionResult> Create([Bind("OrderId,FirstName,LastName,IdentityNo,Address,PostalCode,City,Email,Phone,Total,OrderCreationDate")] Order order) { var cart = CartLogic.GetCart(_context, HttpContext); await cart.SetOrderIdNo(order); if (ModelState.IsValid) { _context.Add(order); HttpContext.Session.Clear(); await _context.SaveChangesAsync(); } return(RedirectToAction(nameof(Details), order)); }
public IActionResult ShowSuggestion() { var cart = CartLogic.GetCart(_context, HttpContext); var suggestion = cart.GetSuggestion(); if (suggestion == null) { return(NotFound()); } int length = suggestion.Count(); Random rand = new Random(); int randIndex = rand.Next(0, length); return(View(suggestion[randIndex])); }
/*----------------------------------------------------------------------------------------------*/ public void CalculateTotalTest3() { //Arrange CartLogic logic = new CartLogic(); Objects.LogicFees fees = new Objects.LogicFees() { Tax = .10m, ShippingFee = 10.0m }; decimal ExpectedValue = 2 * 0 + 0 + 10; //Act decimal Actual = logic.CalculateTotal(null, fees); //Assert Assert.AreEqual(Actual, ExpectedValue); }
private async void decreseQuantity_Tapped(object sender, EventArgs e) { try { var image = (Frame)sender; if (image.GestureRecognizers.Count > 0) { var tapGesture = (TapGestureRecognizer)image.GestureRecognizers[0]; var Item = (Product)tapGesture.CommandParameter; int quantityItem = Item.cart_quantity; if (quantityItem > 1) { Config.ShowDialog(); quantityItem -= 1; Dictionary <string, string> CartItem = new Dictionary <string, string>(); CartItem.Add("product_id", Item.id.ToString()); CartItem.Add("quantity", quantityItem.ToString()); CartItem.Add("update_type", "quantity"); CartItem.Add("user_id", Application.Current.Properties["user_id"].ToString()); var response = await CartLogic.UpdateCart(CartItem); if (response.status == 200) { getData(); } else { Config.ErrorSnackbarMessage(response.message); } Config.HideDialog(); } else { DeleteProduct(Item); } } } catch (Exception ex) { Config.ErrorStore("CartPage-decreseQuantity_Clicked", ex.Message); Config.HideDialog(); } }
public async void ItemClicked(object sender, EventArgs e) { try { var button = sender as Button; CheckoutPage.coupon = button.CommandParameter as Coupon; var response = await CartLogic.ApplyCoupon(Application.Current.Properties["user_id"].ToString(), CheckoutPage.coupon.id.ToString()); if (response.status == 200) { await Navigation.PopAsync(); } else { await DisplayAlert("Alert", response.message, "Ok"); } } catch { } }
public SubscriptionList OnlinePayment(string userId) { List <UserSubscription> subsList = new List <UserSubscription>(); CartLogic cartLogic = new CartLogic() { UserManager = UserManager, RoleManager = RoleManager }; UserSubscriptionLogic userSubLogic = new UserSubscriptionLogic() { UserManager = UserManager, RoleManager = RoleManager }; var cartItems = cartLogic.GetCartItems(userId); if (cartItems.Count > 0) { foreach (CartItem item in cartItems) { UserSubscription usersubs = new UserSubscription() { UserId = userId, SubscriptionTypeId = item.SubscriptionTypeId, ActivationDate = DateTime.Now.Date, Quantity = item.Quantity }; usersubs.ExpireDate = usersubs.ActivationDate.AddDays(item.SubType.ActiveDays).Date; subsList.Add(usersubs); } var dataList = userSubLogic.CreateUserSubscriptionList(subsList, userId); foreach (var item in cartItems) { item.IsPurchased = true; cartLogic.UpdateCartItem(item); } return(dataList); } else { ErrorMessage = cartLogic.ErrorMessage; return(null); } }
private async void btnOrder_Clicked(object sender, EventArgs e) { try { var button = (StackLayout)sender; if (button.GestureRecognizers.Count() > 0) { Config.ShowDialog(); var label = (TapGestureRecognizer)button.GestureRecognizers[0]; var product = (PastOrder)label.CommandParameter; Dictionary <string, string> addToCart = new Dictionary <string, string>(); addToCart.Add("product_id", product.product_id.ToString()); addToCart.Add("user_id", Application.Current.Properties["user_id"].ToString()); addToCart.Add("quantity", product.quantity.ToString()); addToCart.Add("scheduled", "0"); addToCart.Add("product_variation_id", product.product_variation_id); addToCart.Add("from_date", DateTime.Now.ToString("yyyy-MM-dd")); addToCart.Add("to_date", DateTime.Now.ToString("yyyy-MM-dd")); var response = await CartLogic.AddToCart(addToCart); if (response.status == 200) { Config.HideDialog(); HomeVM.MyCartCounter = response.cart_count; MessagingCenter.Send((App)Application.Current, "NavigationBar", ""); Config.SnackbarMessage(response.message); } else { Config.HideDialog(); Config.ErrorSnackbarMessage(Config.ApiErrorMessage); } } } catch (Exception ex) { Config.ErrorStore("PastOrderPage-btnOrder_Clicked", ex.Message); Config.HideDialog(); Config.ErrorSnackbarMessage(Config.ApiErrorMessage); } }