public Task <IActionResult> ProductUpdatePrice(int PriceListID, double newPrice) { return(Task.Run <IActionResult>(() => { try { if (!Request.IsAdmin()) { return Json("Nisi admin!"); } PriceList.Item t = PriceList.Item.List().Where(t => t.ID == PriceListID).FirstOrDefault(); if (t == null) { return Json("Product not found!"); } t.Price = newPrice; t.Update(); return Json("Success"); } catch (Exception ex) { AR.ARDebug.Log(ex.Message); return Json(ex.Message); } })); }
public static double GetValueWithDiscount(this AR.WebShop.Cart cart, int userID) { double value = 0; List <AR.WebShop.Cart.Item> items = cart.GetItems(); User <MoreInformationAboutUser> user = User <MoreInformationAboutUser> .GetUser(userID); PriceList pl = PriceList.GetPriceList(user.PriceListID); foreach (AR.WebShop.Cart.Item item in items) { PriceList.Item plItem = pl.GetItem(item.ProductID); value += item.Quantity * (plItem.Price + (plItem.Price * (plItem.GetDiscount(item.Quantity) / 100))); } return(value); }