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 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))); } }
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))); } }