public IActionResult OrderInvoiceDetail(GetOrderInvoiceDetailModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    string scheme = this.Request.Scheme;
                    scheme += "://" + this.Request.Host + this.Request.PathBase;

                    var orderInvoiceDetail = iOrderInvoice.GetOrderInvoiceDetail(DBHelper.ParseInt64(model.orderInvoiceId));
                    if (orderInvoiceDetail != null)
                    {
                        PromoCode promoCode = null;
                        if (orderInvoiceDetail[0].OrderInvoice.DiscountAmount > 0)
                        {
                            promoCode = iPromoCode.GetPromocodeDetail(DBHelper.ParseInt64(orderInvoiceDetail[0].OrderInvoice.Order.PromocodeFK));
                        }
                        OrderInvoiceDetailModel orderInvoiceDetailList = OrderInvoiceHelper.BindOrderInvoiceDetailModel(orderInvoiceDetail, promoCode);
                        List <long>             productIds             = OrderInvoiceHelper.GetProductIds(orderInvoiceDetailList);
                        List <long>             sizeIds = OrderInvoiceHelper.GetSizeIds(orderInvoiceDetailList);
                        var productCategoryDetails      = iProduct.GetProductCategoryDetail(productIds);
                        var productSizeDetail           = iProduct.GetProductSizeDetails(productIds);
                        var sizeDetail = iSize.GetSizeDetailsBySizeIds(sizeIds);
                        List <ProductImage> productImages = iProduct.GetProductImagesByProductIds(productIds);
                        orderInvoiceDetailList = OrderInvoiceHelper.BindOrderInvoiceDetailImageToModel(orderInvoiceDetailList, scheme, productImages);
                        orderInvoiceDetailList = OrderInvoiceHelper.BindOrderInvoiceProductCategoryToModel(orderInvoiceDetailList, productCategoryDetails);

                        orderInvoiceDetailList = OrderInvoiceHelper.BindOrderInvoiceProductSizeToModel(orderInvoiceDetailList, productSizeDetail, sizeDetail);
                        return(Ok(ResponseHelper.Success(orderInvoiceDetailList)));
                    }
                    else
                    {
                        return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound)));
                    }
                }
                else
                {
                    return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
                return(Ok(ResponseHelper.Error(ex.Message)));
            }
        }
Beispiel #2
0
        public IActionResult GetOrderInvoice(DeleteOrderModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var header      = this.Request.Headers;
                    var authToken   = header["Authorization"];
                    var jwt         = authToken[0].Replace("Bearer ", "");
                    var handler     = new JwtSecurityTokenHandler();
                    var token       = handler.ReadJwtToken(jwt);
                    var loginUserId = DBHelper.ParseInt32(token.Payload["UserId"]);

                    string scheme = this.Request.Scheme;
                    scheme += "://" + this.Request.Host + this.Request.PathBase;
                    var orderDetailModel       = iOrder.GetOrderDetail(model.OrderId);
                    var orderInvoiceSizeDetail = iOrderInvoice.GetOrderInvoiceSizeDetails(model.OrderId);
                    var productIds             = OrderInvoiceHelper.GetProductIds(orderDetailModel);
                    var sizeIds                 = OrderInvoiceHelper.GetSizeIds(orderDetailModel);
                    var productSizeRatio        = iProduct.GetProductSizeDetails(productIds);
                    var productImages           = iProduct.GetProductImagesByProductIds(productIds);
                    var sizeDetail              = iSize.GetSizeDetailsBySizeIds(sizeIds);
                    var getOrderInvoiceModel    = OrderInvoiceHelper.BindGetorderInvoiceDetailModel(orderDetailModel, orderInvoiceSizeDetail, productSizeRatio, scheme, productImages, sizeDetail);
                    var adminUserAddressDetails = iOrderInvoice.GetAdminUserAddressDetails(loginUserId);
                    getOrderInvoiceModel.AdminUserDetails = adminUserAddressDetails;
                    return(Ok(ResponseHelper.Success(getOrderInvoiceModel)));
                }
                else
                {
                    return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
                }
            }
            catch (Exception ex)
            {
                LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
                return(Ok(ResponseHelper.Error(ex.Message)));
            }
        }