public async Task <ActionResult <ShoppingModel> > GetShopping(string userName) { var basket = await _basketService.GetBasket(userName); foreach (var item in basket.Items) { var product = await _catalogService.GetCatalog(item.ProductId); // set additional product fields onto basket item item.ProductName = product.Name; item.Category = product.Category; item.Summary = product.Summary; item.Description = product.Description; item.ImageFile = product.ImageFile; } var orders = await _orderService.GetOrdersByUserName(userName); var shoppingModel = new ShoppingModel { UserName = userName, BasketWithProducts = basket, Orders = orders }; return(Ok(shoppingModel)); }
public ActionResult Add(string sku, int qty) { ProductMaster prod = App.App.MyProducts.Where(i => i.SKU == sku).FirstOrDefault(); OrderDetail order = new OrderDetail() { QTY = qty, products = prod, orderNumber = int.Parse(DateTime.Now.ToString("yyHHmmss")) }; if (App.App.Cart.orders.Exists(i => i.products.SKU == sku)) { OrderDetail modify = App.App.Cart.orders.Where(i => i.products.SKU == sku).FirstOrDefault(); App.App.Cart.orders.Remove(modify); modify.QTY += qty; App.App.Cart.orders.Add(modify); } else { App.App.Cart.orders.Add(order); } int count = App.App.Cart.orders.Count; ShoppingModel shoppingmodels = new ShoppingModel(); shoppingmodels.products = App.App.MyProducts; shoppingmodels.cart = App.App.Cart; return(View("../Home/Index", shoppingmodels)); }
public UnitOfWork(ShoppingModel dataContext) { _dataContext = dataContext; Customer = new CustomerRepository(_dataContext); Product = new ProductRepository(_dataContext); Order = new OrderRepository(_dataContext); }
public async Task <ActionResult <ShoppingModel> > GetShopping(string userName) { // Get the basket for the user var basket = await _basketService.GetBasket(userName); // foreach basket item, get the product and add its attribute to the basket item foreach (var item in basket.Items) { var product = await _catalogService.GetCatalog(item.ProductId); item.ProductName = product.Name; item.ParentCategoryCode = product.ParentCategoryCode; item.Summary = product.Summary; item.Description = product.Description; item.SmallImageURL = product.SmallImageURL; item.MediumImageURL = product.MediumImageURL; item.LargeImageURL = product.LargeImageURL; } // Get the orders for the user var orders = await _orderService.GetOrdersByUserName(userName); // Return the shopping model var result = new ShoppingModel { UserName = userName, BasketWithProducts = basket, Orders = orders }; return(Ok(result)); }
public ShoppingBusiness(string itemName, int userId, int homeId) { shoppingModel = new ShoppingModel(); shoppingModel.ItemName = itemName; shoppingModel.ResponsibleUserId = userId; shoppingModel.HomeId = homeId; }
public async Task <ActionResult <ShoppingModel> > GetShopping(string userName) { // get basket with username // iterate basket items and consume products with basket item productId member // map product related members into basketitem dto with extended columns // consume ordering microservices in order to retrieve order list // return root ShoppingModel dto class which including all responses var basket = await _basketService.GetBasket(userName); foreach (var item in basket.Items) { var product = await _catalogService.GetCatalog(item.ProductId); // set additional product fields onto basket item item.ProductName = product.Name; item.Category = product.Category; item.Summary = product.Summary; item.Description = product.Description; item.ImageFile = product.ImageFile; } var orders = await _orderService.GetOrdersByUserName(userName); var shoppingModel = new ShoppingModel { UserName = userName, BasketWithProducts = basket, Orders = orders }; return(Ok(shoppingModel)); }
public ActionResult Index() { ShoppingModel shopingmodels = new ShoppingModel(); shopingmodels.products = App.App.MyProducts; shopingmodels.cart = App.App.Cart; return(View(shopingmodels)); }
public ActionResult Clear() { App.App.Cart.orders = new List <OrderDetail>(); ShoppingModel shoppingmodels = new ShoppingModel(); shoppingmodels.products = App.App.MyProducts; shoppingmodels.cart = App.App.Cart; return(View("../Home/Index", shoppingmodels)); }
public async Task ToggleShopping(ShoppingModel shoppingModel) { using (var context = dbFactory.CreateDbContext()) { var shoppingItem = context.ShoppingItems.SingleOrDefault(s => s.Id == shoppingModel.Id); if (shoppingItem != null) { shoppingItem.PickTime = shoppingModel.PickTime; context.Update(shoppingItem); await context.SaveChangesAsync(); } } }
public async Task <IActionResult> Edit(int id, [Bind("ShoppingId,Nome,CNPJ,Email,EnderecoId")] ShoppingModel shoppingModel) { if (id != shoppingModel.EnderecoId) { return(NotFound()); } if (ModelState.IsValid) { await _repositoryShopping.UpdateAsync(id, shoppingModel); return(RedirectToAction(nameof(Index))); } ViewData["EnderecoId"] = new SelectList(_repositoryEndereco.GetAll(), "EnderecoId", "Rua"); return(View(shoppingModel)); }
public async Task InitializeLadderProcess() { if (HasBuiltLadderProcess) { return; } Debug.WriteLine("Building ladder process..."); // Browsers are single-threaded so this will actually still block the UI. // See: https://github.com/aspnet/Blazor/issues/560 LadderProcess ladder = await Task.Run(() => Build.CreateLadderProcess()); Debug.WriteLine("Ladder process built."); Ladder = new LadderModel(ladder); Shopping = new ShoppingModel(ladder); ExportToAuno = new ExportToAunoModel(ladder); HasBuiltLadderProcess = true; }
public void Post([FromBody] ShoppingModel model) { var data = JsonConvert.SerializeObject(model); var body = Encoding.UTF8.GetBytes(data); var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (var channel = connection.CreateModel()) { channel.QueueDeclare("shopping", false, false, false, null); channel.BasicPublish("", "shopping", null, body); } }
public async Task <IActionResult> Create([Bind("ShoppingId,Nome,CNPJ,Email,EnderecoId")] ShoppingModel shoppingModel) { if (ModelState.IsValid) { var currentUser = await _userManager.GetUserAsync(User); if (currentUser == null) { return(Unauthorized()); } shoppingModel.OwnerId = currentUser.Id; await _repositoryShopping.InsertAsync(shoppingModel); return(RedirectToAction(nameof(Index))); } ViewData["EnderecoId"] = new SelectList(await _repositoryShopping.GetAllAsync(), "EnderecoId", "Rua", shoppingModel.EnderecoId); return(View(shoppingModel)); }
public void AddShoppingItem(ShoppingModel shoppingModel) { using (SweetHomeEntities she = new SweetHomeEntities()) { try { she.Shopping.Add(new Shopping { Name = shoppingModel.ItemName, ResponsibleUserId = shoppingModel.ResponsibleUserId, HomeId = shoppingModel.HomeId }); she.SaveChanges(); } catch (Exception ex) { throw ex; } } }
public async Task PushProduct(ShoppingModel product) { await Clients.All.SendAsync("GetProduct", product); }
public async Task ToggleShopping(ShoppingModel shoppingModel) { await http.PostAsJsonAsync("Article/Shop", shoppingModel); }
public UnitOfWork(ShoppingModel context) { _context = context; }
public ProductRepository(ShoppingModel dataContext) : base(dataContext) { _context = dataContext; }
public IUnitOfWork CreateUoWInstance() { var dataContext = new ShoppingModel(); return(new UnitOfWork(dataContext)); }
protected Repository(ShoppingModel dataContext) { _dataContext = dataContext; dbset = _dataContext.Set <T>(); }
public OrderRepository(ShoppingModel dataContext) : base(dataContext) { _context = dataContext; }
public void UpdateShoppingItem(ShoppingModel shoppingModel) { throw new NotImplementedException(); }
public async Task SetShoppingItem(ShoppingModel shoppingModel) { await articleService.ToggleShoppingItem(shoppingModel); }
/// <summary> /// Ctor /// </summary> /// <param name="context">Object context</param> public GenericRepository(ShoppingModel context) { this._context = context; }