Пример #1
0
 public IActionResult AddOrderInvoice(AddOrderInvoiceModel orderInvoiceModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             decimal discountAmount = 0;
             decimal percentage     = 0;
             long    invoiceCount   = iOrderInvoice.GetInvoiceCountByOrderId(DBHelper.ParseInt64(orderInvoiceModel.OrderId));
             if (invoiceCount <= 0)
             {
                 var orderModel = iOrder.GetOrderModelByOrderId(DBHelper.ParseInt64(orderInvoiceModel.OrderId));
                 if (orderModel != null && orderModel.PromocodeFK.HasValue)
                 {
                     var promoCodeModel = iPromoCode.GetPromocodeDetail(DBHelper.ParseInt64(orderModel.PromocodeFK));
                     if (promoCodeModel != null)
                     {
                         discountAmount = promoCodeModel.Amount;
                         percentage     = promoCodeModel.Percentage;
                     }
                 }
             }
             var          uniqueInvoiceIds = iOrderInvoice.GetAllUniqueInvoiceIds();
             OrderInvoice orderInvModel    = OrderInvoiceHelper.BindOrderInvoice(orderInvoiceModel, uniqueInvoiceIds, discountAmount, percentage);
             List <OrderInvoiceDetail> invoiceDetailsList = OrderInvoiceHelper.BindOrderInvoiceDetailModel(orderInvoiceModel.productDetail);
             long orderInvoiceId = iOrderInvoice.AddOrderInvoice(orderInvModel, invoiceDetailsList, orderInvoiceModel.productDetail);
             if (orderInvoiceId > 0)
             {
                 if (orderInvModel.OrderStatusFK == OrderStatusEnum.ReadyforPayment.GetHashCode())
                 {
                     SendPaymentRelatedEmail(DBHelper.ParseInt32(orderInvoiceId));
                 }
                 return(Ok(ResponseHelper.Success(MessageConstants.OrderInvoiceGenerated)));
             }
             else
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.OrderInvoiceNotGenerated)));
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.CompulsoryData)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
Пример #2
0
 public IActionResult PromocodeDetail(GetPromoCodeDetailModel promoCodeDetailModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             var promocodeDetail = iPromoCode.GetPromocodeDetail(DBHelper.ParseInt64(promoCodeDetailModel.promoCodeId));
             if (promocodeDetail != null)
             {
                 PromoCodeDataListModel promoCodeListModel = PromoCodeHelper.BindPromoCodeListModel(promocodeDetail);
                 return(Ok(ResponseHelper.Success(promoCodeListModel)));
             }
             else
             {
                 return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound)));
             }
         }
         else
         {
             return(Ok(ResponseHelper.Error(MessageConstants.DataNotFound)));
         }
     }
     catch (Exception ex)
     {
         LogHelper.ExceptionLog(ex.Message + "  :::::  " + ex.StackTrace);
         return(Ok(ResponseHelper.Error(ex.Message)));
     }
 }
Пример #3
0
        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)));
            }
        }