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));
     }
 }
示例#2
0
 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));
     }
 }
示例#3
0
 public async Task <IActionResult> Index()
 {
     return(View(await _productQueryService.GetAll()));
 }
示例#4
0
 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)));
 }