public HttpResponseMessage GetById(HttpRequestMessage request, int id) { return(CreateHttpResponse(request, () => { var model = _priceService.GetById(id); var responseData = Mapper.Map <Price, PriceViewModel>(model); var response = request.CreateResponse(HttpStatusCode.OK, responseData); return response; })); }
public JsonResult Add(int Id, int Quantity = 1) { var cart = (List <ShoppingCartViewModel>)Session[CommonConstants.SessionCart]; var PriceProduct = _priceService.GetById(Id); var PriceProductAll = _priceService.GetAll().ToList(); //var product = _productService.GetById(PriceProduct.ProductID); if (cart == null) { cart = new List <ShoppingCartViewModel>(); } //if (product.Quantity == 0) //{ // return Json(new // { // status = false, // message = "Sản phẩm này hiện đang hết hàng" // }); //} if (cart.Any(x => x.Id == Id)) { foreach (var item in cart) { if (item.Id == Id) { item.Quantity += Quantity; } } } else { ShoppingCartViewModel newItem = new ShoppingCartViewModel(); Product product = _productService.GetById(PriceProduct.ProductID); product.Price = PriceProduct.SalePrice; product.PromotionPrice = PriceProduct.PromotionPrice; newItem.Product = Mapper.Map <Product, ProductViewModel>(PriceProduct.Product); newItem.Id = PriceProduct.ID; newItem.ProductId = PriceProduct.Product.ID; newItem.Quantity = Quantity; newItem.SalePrice = PriceProduct.SalePrice; newItem.PromotionPrice = PriceProduct.PromotionPrice; newItem.SizeId = PriceProduct.SizeID; newItem.ColorId = PriceProduct.ColorID; newItem.ColorName = _colorService.GetById(PriceProduct.ColorID).Name; newItem.SizeName = _sizeService.GetById(PriceProduct.SizeID).Name; cart.Add(newItem); } Session[CommonConstants.SessionCart] = cart; return(Json(new { status = true, data = cart })); }
public IActionResult Details(int id) { var price = _priceService.GetById(id); if (price == null) { return(NotFound()); } return(Ok(price)); }
public IActionResult GetById(int id) { var result = _priceService.GetById(id); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); }
public async Task <CombinedProduct> GetById(string code) { var productTask = productService.GetById(code); var priceTask = priceService.GetById(code); await Task.WhenAll(productTask, priceTask); var product = productTask.Result; var price = priceTask.Result; return(Combine(product, price)); }
public ApiResultModel <PRECIO> GetById([FromUri] int id) => GetApiResultModel(() => _priceService.GetById <PRECIO>(id));
public IActionResult PriceDesc_Edit(int id = 0) { PriceDesc model = (id > 0) ? service.GetById <PriceDesc>(id) : new PriceDesc(); return(View(model)); }