public IActionResult EmailOrderInvoice(GetOrderInvoiceDetailModel 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 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 <ProductImage> productImages = iProduct.GetProductImagesByProductIds(productIds); orderInvoiceDetailList = OrderInvoiceHelper.BindOrderInvoiceDetailImageToModel(orderInvoiceDetailList, scheme, productImages); var adminUserAddressDetails = iOrderInvoice.GetAdminUserAddressDetails(loginUserId); orderInvoiceDetailList.AdminUserDetails = adminUserAddressDetails; if (orderInvoiceDetailList != null) { var HostingPath = env.ContentRootPath; string clientEmail = config.GetValue <string>("app_settings:ClientEmail"); string clientEmailPassword = config.GetValue <string>("app_settings:ClientEmailPassword"); string port = config.GetValue <string>("app_settings:Port"); string mailHost = config.GetValue <string>("app_settings:SMTPURL"); string host = this.Request.Host.Value; OrderHelper.SendInvoice(orderInvoiceDetailList.Email, orderInvoiceDetailList, DBHelper.ParseString(HostingPath), clientEmail, clientEmailPassword, port, mailHost, host, scheme); } 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))); } }
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))); } }
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))); } }