public LogicResult <ProductInvoiceModel> GetInvoiceForDownload(Guid productId, Guid userId) { try { var invoice = (from userToProduct in _userToProductQueryService.GetAll() join product in _productQueryService.GetAll() on userToProduct.ProductId equals product.Id join productType in _productTypeServiceFacade.Data on product.TypeId equals productType.Id where userToProduct.UserId == userId && userToProduct.ProductId == productId select new ProductInvoiceModel { Day = userToProduct.Day, UserId = userToProduct.UserId, Point = userToProduct.Point, Id = userToProduct.ProductId, PaymentDetail = SerializerHelper.DeserializeObject <PaymentDetail>(userToProduct.PaymentDetail), Name = product.Name, Type = productType.Type }).FirstOrDefault(); return(LogicResult <ProductInvoiceModel> .Succeed(invoice)); } catch { return(LogicResult <ProductInvoiceModel> .Failure(Validation.UnSuccessfullOperation)); } }
public LogicResult <ProductCartModel> GetProductDetailForAddToCart(Guid productId) { try { var model = (from product in _productQueryService.GetAll() join productType in _productTypeServiceFacade.Data on product.TypeId equals productType.Id where product.Id == productId select new ProductCartModel { Id = product.Id, Name = product.Name, Type = productType.Type, Point = productType.Point, UserId = CurrentUser.Id }).FirstOrDefault(); var priceDetail = new PriceDetail { Type = model.Type.ToEnum <ProductType>() }; var paymentDetailResult = _priceCalculationService.CalculatePrice(priceDetail); if (paymentDetailResult.IsSucceed) { model.PaymentDetail = paymentDetailResult.Data; return(LogicResult <ProductCartModel> .Succeed(model)); } else { return(LogicResult <ProductCartModel> .Failure(Validation.UnSuccessfullOperation)); } } catch { return(LogicResult <ProductCartModel> .Failure(Validation.UnSuccessfullOperation)); } }
public async Task <IActionResult> Index() { return(View(await _productQueryService.GetAll())); }
public virtual IEnumerable <ProductDTO> GetAll() { return(_productQueryService.GetAll()); }
//[Authorize(Roles = "Support,Admin")] public IHttpActionResult Get(Guid?brandId = null, Guid?categoryRootId = null, Guid?subCategoryId = null) { return(Ok(_productQueryService.GetAll(brandId, categoryRootId, subCategoryId))); }