public static ProductVariantDetail RemoveReferences(this ProductVariantDetail item) { var obj = new ProductVariantDetail(); obj = item?.RemoveReference(); if (item?.Product != null) { obj.Product = new Product(); obj.Product = item.Product.RemoveReference(); } if (item?.ProductVariantOptions.Count > 0) { obj.ProductVariantOptions = new List <Models.ProductVariantOption>(); obj.ProductVariantOptions = item.ProductVariantOptions.ToList().RemoveReferences(); } if (item?.ProductImages.Count > 0) { obj.ProductImages = new List <Models.ProductImage>(); obj.ProductImages = item.ProductImages.ToList().RemoveReferences(); } if (item?.CartItems != null && item.CartItems.Count > 0) { obj.CartItems = new List <Models.CartItem>(); obj.CartItems = item.CartItems.ToList().RemoveReferences(); } return(obj); }
//for product detai; public static ProductVariantDetail calculateDealForProductDetailModel(ProductVariantDetail Data, PistisContext db) { var finaldDeal = deals(db); var dealpro = new List <DealProduct>(); foreach (var f in finaldDeal) { dealpro.AddRange(f.DealProduct); } var pi = Convert.ToInt32(db.ProductVariantDetails.Where(x => x.Id == Data.Id).Include(x => x.Product.ProductCategory).FirstOrDefault().Product?.ProductCategory?.ParentId); var catid = getparentCat(pi, db); Data.Commission = GetCommissionByCategoryId(catid, db); if (dealpro.Any(z => z.ProductVariantId == Data.Id)) { foreach (var p in dealpro.Where(z => z.ProductVariantId == Data.Id)) { Data.Discount = Data.Discount + Convert.ToInt32(p.Deal.Discount); var priceaftercomm = Data.Price + (Data.Price * Data.Commission / 100); Data.Price = priceaftercomm; Data.PriceAfterdiscount = (priceaftercomm - (priceaftercomm * Data.Discount / 100)); Data.ActiveTo = p.Deal.ActiveTo; } } else { Data.Discount = Data.Discount; var priceaftercomm = Data.Price + (Data.Price * Data.Commission / 100); Data.Price = priceaftercomm; Data.PriceAfterdiscount = (priceaftercomm - (priceaftercomm * Data.Discount / 100)); } return(Data); }
public static ProductVariantDetail calculatePriceForProductDetailModel(ProductVariantDetail d, PistisContext db) { var increment = db.PaymentConfiguration.Where(x => x.IsApplied == true).FirstOrDefault(); if (increment != null) { if (d.Price >= increment.Amount) { d.Price = d.Price + (d.Price * increment.Percentage / 100); d.PriceAfterdiscount = (d.Price - (d.Price * d.Discount / 100)); } } return d; }
private static ProductVariantDetail RemoveReference(this ProductVariantDetail item) { var obj = new ProductVariantDetail(); if (item != null) { obj.Id = item.Id; obj.InStock = item.InStock; obj.IsActive = item.IsActive; obj.IsDefault = item.IsDefault; obj.Price = item.Price; obj.ProductId = item.ProductId; obj.Weight = item.Weight; obj.ProductSKU = item.ProductSKU; obj.Discount = item.Discount; obj.PriceAfterdiscount = item.PriceAfterdiscount; } return(obj); }
//public static string fillXmlForCapability(capabilityRequestModel requestModel, string _siteId, string _sitePassword, PistisContext db) //{ // //var productData = db.ProductVariantDetails.Where(b => b.IsActive == true && b.Id == requestModel.variantDetailId).Include(b => b.Product).FirstOrDefault(); // //if (productData == null) // // return null; // XmlSerializer serialization = new XmlSerializer(typeof(DCTRequest)); // DCTRequest dcr = new DCTRequest(); // dcr.GetQuote = new GetQuote(); // dcr.GetQuote.Request = new GetQuoteRequest(); // dcr.GetQuote.Request.ServiceHeader = new GetQuoteRequestServiceHeader(); // dcr.GetQuote.From = new GetQuoteFrom(); // dcr.GetQuote.BkgDetails = new GetQuoteBkgDetails(); // dcr.GetQuote.BkgDetails.Pieces = new GetQuoteBkgDetailsPieces(); // dcr.GetQuote.BkgDetails.Pieces.Piece = new GetQuoteBkgDetailsPiecesPiece(); // dcr.GetQuote.To = new GetQuoteTO(); // dcr.GetQuote.Request.ServiceHeader.SiteID = _siteId; // dcr.GetQuote.Request.ServiceHeader.Password = _sitePassword; // dcr.GetQuote.From.CountryCode = "MX"; // dcr.GetQuote.From.Postalcode = 15700; // dcr.GetQuote.BkgDetails.PaymentCountryCode = "MX"; // dcr.GetQuote.BkgDetails.Date = DateTime.UtcNow; // dcr.GetQuote.BkgDetails.ReadyTime = "PT10H21M"; // dcr.GetQuote.BkgDetails.DimensionUnit = "CM"; // dcr.GetQuote.BkgDetails.WeightUnit = "KG"; // dcr.GetQuote.BkgDetails.Pieces.Piece.PieceID = 1; // dcr.GetQuote.BkgDetails.Pieces.Piece.PackageTypeCode = "FLY"; // dcr.GetQuote.BkgDetails.Pieces.Piece.Height = 0; // dcr.GetQuote.BkgDetails.Pieces.Piece.Depth = 0; // dcr.GetQuote.BkgDetails.Pieces.Piece.Width = 0; // dcr.GetQuote.BkgDetails.Pieces.Piece.Weight = 6; // dcr.GetQuote.To.CountryCode = requestModel.CountryCode; // dcr.GetQuote.To.Postalcode = requestModel.Postalcode; // var result = ""; // XmlWriterSettings settings = new XmlWriterSettings(); // settings.Encoding = new UnicodeEncoding(false, false); // settings.Indent = true; // settings.OmitXmlDeclaration = true; // using (StringWriter textWriter = new StringWriter()) // { // using (XmlWriter xmlWriter = XmlWriter.Create(textWriter, settings)) // { // serialization.Serialize(xmlWriter, dcr); // } // result = textWriter.ToString(); // } // return result; //} public static string fillXmlForQuote(capabilityRequestModel requestModel, string _siteId, string _sitePassword, PistisContext db, ProductVariantDetail productData, User vendorData) { int Qtd = 2; if (productData == null) { return(null); } XmlSerializer serialization = new XmlSerializer(typeof(DCTRequest)); DCTRequest dcr = new DCTRequest(); dcr.GetQuote = new GetQuote(); dcr.GetQuote.Request = new GetQuoteRequest(); dcr.GetQuote.Request.ServiceHeader = new GetQuoteRequestServiceHeader(); dcr.GetQuote.Request.MetaData = new GetQuoteRequestMetaData(); dcr.GetQuote.From = new GetQuoteFrom(); dcr.GetQuote.BkgDetails = new GetQuoteBkgDetails(); dcr.GetQuote.BkgDetails.Pieces = new GetQuoteBkgDetailsPieces(); dcr.GetQuote.BkgDetails.Pieces.Piece = new GetQuoteBkgDetailsPiecesPiece(); dcr.GetQuote.BkgDetails.QtdShp = new GetQuoteBkgDetailsQtdShpExChrg[Qtd]; dcr.GetQuote.To = new GetQuoteTO(); dcr.GetQuote.Dutiable = new GetQuoteDutiable(); dcr.GetQuote.Request.ServiceHeader.MessageTime = DateTime.UtcNow; dcr.GetQuote.Request.ServiceHeader.MessageReference = "de28a010e5d441d8a5dfb3d2cadd99a8"; dcr.GetQuote.Request.ServiceHeader.SiteID = _siteId; dcr.GetQuote.Request.ServiceHeader.Password = _sitePassword; dcr.GetQuote.Request.MetaData.SoftwareName = "3PV"; dcr.GetQuote.Request.MetaData.SoftwareVersion = 1; dcr.GetQuote.From.CountryCode = "MX"; dcr.GetQuote.From.Postalcode = "11290"; dcr.GetQuote.BkgDetails.PaymentCountryCode = "MX"; dcr.GetQuote.BkgDetails.Date = DateTime.UtcNow; dcr.GetQuote.BkgDetails.ReadyTime = "PT10H21M"; dcr.GetQuote.BkgDetails.DimensionUnit = "CM"; dcr.GetQuote.BkgDetails.WeightUnit = "KG"; dcr.GetQuote.BkgDetails.Pieces.Piece.PieceID = 1; //dcr.GetQuote.BkgDetails.Pieces.Piece.PackageTypeCode = "FLY"; dcr.GetQuote.BkgDetails.Pieces.Piece.Height = 0; dcr.GetQuote.BkgDetails.Pieces.Piece.Depth = 0; dcr.GetQuote.BkgDetails.Pieces.Piece.Width = 0; dcr.GetQuote.BkgDetails.Pieces.Piece.Weight = (1 * requestModel.quantity); dcr.GetQuote.BkgDetails.PaymentAccountNumber = 980039904; dcr.GetQuote.BkgDetails.IsDutiable = "N"; for (int i = 0; i < Qtd; i++) { dcr.GetQuote.BkgDetails.QtdShp[i] = new GetQuoteBkgDetailsQtdShpExChrg(); dcr.GetQuote.BkgDetails.QtdShp[i].SpecialServiceType = "OSINFO"; if (i > 0) { dcr.GetQuote.BkgDetails.QtdShp[i].SpecialServiceType = "TK"; } dcr.GetQuote.BkgDetails.QtdShp.Append(dcr.GetQuote.BkgDetails.QtdShp[i]); } dcr.GetQuote.To.CountryCode = requestModel.CountryCode; dcr.GetQuote.To.Postalcode = requestModel.Postalcode; dcr.GetQuote.Dutiable.DeclaredCurrency = "USD"; dcr.GetQuote.Dutiable.DeclaredValue = 83; var result = ""; XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UnicodeEncoding(false, false); settings.Indent = true; settings.OmitXmlDeclaration = true; using (StringWriter textWriter = new StringWriter()) { using (XmlWriter xmlWriter = XmlWriter.Create(textWriter, settings)) { serialization.Serialize(xmlWriter, dcr); } result = textWriter.ToString(); } return(result); }
public static Envelope CreateRateRequest(capabilityRequestModel requestModel, IOptions <AppSettings> _settings, PistisContext db, ProductVariantDetail productData, User vendorData) { try { var request = new Envelope(); request.Body = new EnvelopeBody(); request.Body.RateRequest = new RateRequest(); request.Body.RateRequest.WebAuthenticationDetail = new RateRequestWebAuthenticationDetail(); request.Body.RateRequest.WebAuthenticationDetail.UserCredential = new RateRequestWebAuthenticationDetailUserCredential(); request.Body.RateRequest.WebAuthenticationDetail.UserCredential.Key = _settings.Value.FedExUserId; request.Body.RateRequest.WebAuthenticationDetail.UserCredential.Password = _settings.Value.FedExPassword; request.Body.RateRequest.ClientDetail = new RateRequestClientDetail(); request.Body.RateRequest.ClientDetail.AccountNumber = (_settings.Value.FedExAccountNumber); request.Body.RateRequest.ClientDetail.MeterNumber = (_settings.Value.FedExMeterNumber); request.Body.RateRequest.TransactionDetail = new RateRequestTransactionDetail(); request.Body.RateRequest.TransactionDetail.CustomerTransactionId = "ENVIO_NACIONAL"; request.Body.RateRequest.Version = new RateRequestVersion(); request.Body.RateRequest.Version.ServiceId = "crs"; request.Body.RateRequest.Version.Major = 24; request.Body.RateRequest.Version.Intermediate = 0; request.Body.RateRequest.Version.Minor = 0; request.Body.RateRequest.ReturnTransitAndCommit = true; request.Body.RateRequest.RequestedShipment = new RateRequestRequestedShipment(); request.Body.RateRequest.RequestedShipment.ShipTimestamp = Convert.ToDateTime(DateTime.Now); request.Body.RateRequest.RequestedShipment.DropoffType = "REGULAR_PICKUP"; request.Body.RateRequest.RequestedShipment.PackagingType = "YOUR_PACKAGING"; request.Body.RateRequest.RequestedShipment.PreferredCurrency = "MXN"; request.Body.RateRequest.RequestedShipment.Shipper = new RateRequestRequestedShipmentShipper(); request.Body.RateRequest.RequestedShipment.Shipper.Contact = new RateRequestRequestedShipmentShipperContact(); request.Body.RateRequest.RequestedShipment.Shipper.Contact.PersonName = "Pranjal shirivastva"; request.Body.RateRequest.RequestedShipment.Shipper.Contact.CompanyName = "Pistis"; request.Body.RateRequest.RequestedShipment.Shipper.Contact.PhoneNumber = ""; request.Body.RateRequest.RequestedShipment.Shipper.Contact.EMailAddress = "*****@*****.**"; request.Body.RateRequest.RequestedShipment.Shipper.Address = new RateRequestRequestedShipmentShipperAddress(); request.Body.RateRequest.RequestedShipment.Shipper.Address.StreetLines = new string[1]; request.Body.RateRequest.RequestedShipment.Shipper.Address.StreetLines[0] = ""; request.Body.RateRequest.RequestedShipment.Shipper.Address.City = "CDMX"; request.Body.RateRequest.RequestedShipment.Shipper.Address.CountryCode = "MX"; request.Body.RateRequest.RequestedShipment.Shipper.Address.PostalCode = "11290"; //request.Body.RateRequest.RequestedShipment.Shipper.Address.StateOrProvinceCode = "DF"; request.Body.RateRequest.RequestedShipment.Recipient = new RateRequestRequestedShipmentRecipient(); request.Body.RateRequest.RequestedShipment.Recipient.Contact = new RateRequestRequestedShipmentRecipientContact(); //request.Body.RateRequest.RequestedShipment.Recipient.Contact.PersonName = "NOMBRE DE DESTINATARIO"; //request.Body.RateRequest.RequestedShipment.Recipient.Contact.CompanyName = "COMPANIA SI APLICA"; //request.Body.RateRequest.RequestedShipment.Recipient.Contact.PhoneNumber = 1236547891; //request.Body.RateRequest.RequestedShipment.Recipient.Contact.EMailAddress = "*****@*****.**"; request.Body.RateRequest.RequestedShipment.Recipient.Address = new RateRequestRequestedShipmentRecipientAddress(); //request.Body.RateRequest.RequestedShipment.Recipient.Address.StreetLines = new string[2]; //request.Body.RateRequest.RequestedShipment.Recipient.Address.StreetLines[0] = "CALLE Y NUMERO"; //request.Body.RateRequest.RequestedShipment.Recipient.Address.StreetLines[1] = "COLONIA"; request.Body.RateRequest.RequestedShipment.Recipient.Address.PostalCode = requestModel.Postalcode; request.Body.RateRequest.RequestedShipment.Recipient.Address.CountryCode = "MX"; //request.Body.RateRequest.RequestedShipment.Recipient.Address.StateOrProvinceCode = "DF"; //request.Body.RateRequest.RequestedShipment.Recipient.Address.City = ; request.Body.RateRequest.RequestedShipment.ShippingChargesPayment = new RateRequestRequestedShipmentShippingChargesPayment(); request.Body.RateRequest.RequestedShipment.ShippingChargesPayment.PaymentType = "SENDER"; request.Body.RateRequest.RequestedShipment.ShippingChargesPayment.Payor = new RateRequestRequestedShipmentShippingChargesPaymentPayor(); request.Body.RateRequest.RequestedShipment.ShippingChargesPayment.Payor.ResponsibleParty = new RateRequestRequestedShipmentShippingChargesPaymentPayorResponsibleParty(); request.Body.RateRequest.RequestedShipment.ShippingChargesPayment.Payor.ResponsibleParty.AccountNumber = (_settings.Value.FedExAccountNumber); request.Body.RateRequest.RequestedShipment.RateRequestTypes = "LIST"; request.Body.RateRequest.RequestedShipment.PackageCount = 1; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems = new RateRequestRequestedShipmentRequestedPackageLineItems(); request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.SequenceNumber = 1; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.GroupNumber = 1; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.GroupPackageCount = 1; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Weight = new RateRequestRequestedShipmentRequestedPackageLineItemsWeight(); request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Weight.Units = "KG"; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Weight.Value = 1; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Dimensions = new RateRequestRequestedShipmentRequestedPackageLineItemsDimensions(); request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Dimensions.Length = 56; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Dimensions.Width = 58; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Dimensions.Height = 58; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.Dimensions.Units = "CM"; request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.ContentRecords = new RateRequestRequestedShipmentRequestedPackageLineItemsContentRecords(); request.Body.RateRequest.RequestedShipment.RequestedPackageLineItems.ContentRecords.Description = "ENVIO DE PRUEBA"; return(request); } catch (Exception ex) { throw ex; } }
internal static string fillXmlForQuote(capabilityRequestModel requestModel, IOptions <AppSettings> _settings, PistisContext db, ProductVariantDetail productData, User vendorData) { var rateRequest = CreateRateRequest(requestModel, _settings, db, productData, vendorData); var result = ""; XmlSerializer serialization = new XmlSerializer(typeof(Envelope)); XmlWriterSettings settings = new XmlWriterSettings(); settings.Encoding = new UnicodeEncoding(false, false); settings.Indent = true; settings.OmitXmlDeclaration = true; using (StringWriter textWriter = new StringWriter()) { using (XmlWriter xmlWriter = XmlWriter.Create(textWriter, settings)) { serialization.Serialize(xmlWriter, rateRequest); } result = textWriter.ToString(); } var reqData = result.Split('\n'); reqData[0] = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:SOAP-ENC=\"http://schemas.xmlsoap.org/soap/encoding/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://fedex.com/ws/rate/v24\">\r\n"; reqData[1] = "<SOAP-ENV:Body>\r\n"; reqData[2] = "<RateRequest>\r\n"; reqData[reqData.Length - 3] = "</RateRequest>\r\n"; reqData[reqData.Length - 2] = "</SOAP-ENV:Body>\r\n"; reqData[reqData.Length - 1] = "</SOAP-ENV:Envelope>\r\n"; result = string.Join("", reqData); return(result); }