/// <summary> /// Default constructor /// </summary> /// <param name="itemPriceWatch">The item's price watch information</param> /// <param name="notificationType">The notification type</param> /// <param name="price">The current price of the item, in copper</param> public PriceNotificationViewModel(ItemPriceViewModel itemPriceWatch, PriceNotificationType notificationType, int price, ICollection <PriceNotificationViewModel> displayedNotificationsCollection) { this.itemPriceWatch = itemPriceWatch; this.notificationType = notificationType; this.price = new Price(); this.price.Value = price; this.isRemovingNotification = false; this.displayedNotifications = displayedNotificationsCollection; }
/// <summary> /// Determines if we can show a notification for the given price notification, based on user settings /// </summary> /// <param name="objectiveData">The price watch's data</param> /// <param name="notificationType">The type of notification</param> /// <returns>True if the notification can be shown, else false</returns> private bool CanShowNotification(ItemPriceViewModel priceWatch, PriceNotificationType notificationType) { bool canShow = false; switch (notificationType) { case PriceNotificationType.BuyOrder: canShow = this.UserData.AreBuyOrderPriceNotificationsEnabled && !priceWatch.IsBuyOrderNotificationShown; break; case PriceNotificationType.SellListing: canShow = this.UserData.AreSellListingPriceNotificationsEnabled && !priceWatch.IsSellListingNotificationShown; break; default: break; } return(canShow); }
public IActionResult SavePizzaPrice([FromBody] ItemPriceViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dbItem = _dataAccess.Pizzas.GetById(new Guid(model.Id)); if (dbItem is null) { return(NotFound()); } _dataAccess.PizzaPrices.Create(new PizzaPrice() { Pizza = dbItem, Date = model.Date, Price = model.Price }); _dataAccess.SaveChanges(); return(Ok()); }
public ActionResult UpdateItemPrice(ItemPriceViewModel model) { itempriceService = new ItemPriceService(context); userService = new UserService(context); bool status = false; //find item price object and assign new price ItemPrice itemPrice = itempriceService.FindItemPriceByItemCode(model.ItemCode).Where(x => x.SupplierCode == model.SupplierCode).First(); itemPrice.Price = model.Price; //assign user info into update fields itemPrice.UpdatedDateTime = DateTime.Now; itemPrice.UpdatedBy = userService.FindUserByEmail(CurrentUserName); if (itempriceService.Save(itemPrice) != null) { status = true; } return(new JsonResult { Data = new { status = status } }); }
public void UpdatePriceListTest() { //Arrange decimal expected = 7.77M; //Instantiate controller SupplierController controller = new SupplierController() { CurrentUserName = "******", context = this.context }; controller.ModelState.Clear(); //get an itemprice object from db ItemPrice itemPrice = context.ItemPrice.Where(x => x.ItemCode == "TEST").First(); //assemble itemprice viewmodel ItemPriceViewModel VM = new ItemPriceViewModel() { ItemCode = itemPrice.ItemCode, SupplierCode = itemPrice.SupplierCode, //change price of itemprice viewmodel Price = expected }; //Act controller.UpdateItemPrice(VM); var result = context.ItemPrice.Where(x => x.ItemCode == "TEST").First(); //Assert Assert.AreEqual(expected, result.Price); }
/// <summary> /// Default constructor /// </summary> /// <param name="itemPriceWatch">The item's price watch information</param> /// <param name="notificationType">The notification type</param> /// <param name="price">The current price of the item, in copper</param> public PriceNotificationViewModel(ItemPriceViewModel itemPriceWatch, PriceNotificationType notificationType, int price, ICollection<PriceNotificationViewModel> displayedNotificationsCollection) { this.itemPriceWatch = itemPriceWatch; this.notificationType = notificationType; this.price = new Price(); this.price.Value = price; this.isRemovingNotification = false; this.displayedNotifications = displayedNotificationsCollection; }
public async Task <int> SaveItemPrice(ItemPriceViewModel itemPriceViewModel) { var itemPrice = Mapper.Map <ItemPrice>(itemPriceViewModel); return(await _itemPriceRepository.SaveItemPrice(itemPrice)); }