public async Task AddProductToListAsync(ProductListItemModel product, bool isPremiumProduct) { var response = await _messageQueueService.SendUserShopRequest(product.UserId, product.ShopId); if (!response.IsAssigned) { _logger.Error($"User '{product.UserId}' doesn't assigned to shop '{product.ShopId}'"); throw new Exception($"User '{product.UserId}' doesn't assigned to shop '{product.ShopId}'"); } _logger.Info("Received userShop response from shop"); var shopProductListId = _unit.ShopProductListRepository .GetByCondition(x => x.ShopId == product.ShopId).FirstOrDefault().Id; try { await _unit.ProductListRepository.CreateAsync(new ProductLists { ProductId = product.ProductId, ShopProductListId = shopProductListId }); await _unit.SaveAsync(); } catch (Exception ex) { if (isPremiumProduct) { await _messageQueueService.SendDecreasePremiumProductsCountEvent(product.AccountId); } throw ex; } }
public ActionResult Add(int quantity, int productId, string productDescription) { List <ProductListItemModel> productLists = new List <ProductListItemModel>(); ProductListItemModel listItemModel = new ProductListItemModel(); listItemModel = findProductListQuery.Execute(productId).SingleOrDefault(); productLists.Add(listItemModel); Session["AddedListOfProducts"] = productLists; return(Json(productLists, JsonRequestBehavior.AllowGet)); }
public static ProductListItemModel ToListItemModel(this Product product) { var productListItemModel = new ProductListItemModel { Id = product.Id, ProductCode = product.ProductCode, ProductName = product.ProductName, SubcategoryName = product.Subcategory?.Name.Trim(), Brand = product.Brand?.Name, Price = product.Price, SalePercentage = product.SalePercentage.ToString() + "%", CategoryName = product.Subcategory?.Category?.Name, SubcategoryId = product.Subcategory?.Id }; return(productListItemModel); }
public void InitializeCollection() { OrderListItemsCollection = new ObservableCollection <OrderListItemModel>(); Context = new NiagaposEntities(); GetOrderListItemModel = new OrderListItemModel(); ProductListItemsCollection = new ObservableCollection <ProductListItemModel>(); GetProductListItemModel = new ProductListItemModel(); ConfirmOrderListItemsCollection = new ObservableCollection <ConfirmOrderListItemModel>(); GetConfirmOrderListItemModel = new ConfirmOrderListItemModel(); TransactionListItemsCollection = new ObservableCollection <TransactionDetailViewModel>(); GetTransactionListItemsModel = new TransactionDetailViewModel(); TransactionModelCollection = new ObservableCollection <Transaction>(); GetTransactionModel = new Transaction(); TransactionDetailModelCollection = new ObservableCollection <TransactionDetail>(); GetTransactionDetailModel = new TransactionDetail(); }