public static Dictionary <string, string> CreateReserve() { Dictionary <string, string> res = new Dictionary <string, string>(); var basket = SessionBasket.GetBasket(); ArticleInfo[] prodInfo = new ArticleInfo[basket.Where(x => x.Key > 0).Count()]; int i = 0; foreach (var key in basket.Keys) { if (key > 0) { prodInfo[i] = new ArticleInfo(key, basket[key]); i++; } } Hashtable pars = new Hashtable(); pars["Articles"] = prodInfo; pars["ReserveOfficeId"] = 1; pars["ObtainMethod"] = "ownStorePickup"; // some magic hardcoded value in ultima2c.. XmlDocument doc = GetXmlResponse("CreateReserve", pars); XmlNamespaceManager nsmgr = doc.NsMan(); string reserveID = doc.DocumentElement.SelectSingleNode(String.Format("{0}:Id", doc.GetPrefix()), nsmgr).InnerText; string deadDate = doc.DocumentElement.SelectSingleNode(String.Format("{0}:DeadDate", doc.GetPrefix()), nsmgr).InnerText; return(new Dictionary <string, string> { { "Id", reserveID }, { "DeadDate", deadDate } }); }
public void ConfigureServices(IServiceCollection services) { services.AddDbContext <DAL.EF.ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataConnection"), b => b.MigrationsAssembly("DAL"))); services.AddDbContext <Identity.EF.ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DataConnection"))); services.AddIdentity <ApplicationUser, ApplicationRole>() .AddEntityFrameworkStores <Identity.EF.ApplicationDbContext>() .AddDefaultTokenProviders(); services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme). AddCookie(options => options.SlidingExpiration = true). AddJwtBearer(options => { options.RequireHttpsMetadata = false; options.SaveToken = true; options.TokenValidationParameters = new TokenValidationParameters { ValidIssuer = AuthOptions.ISSUER, ValidateAudience = true, ValidAudience = AuthOptions.AUDIENCE, ValidateLifetime = true, IssuerSigningKey = AuthOptions.GetSymmetricSecurityKey(), ValidateIssuerSigningKey = true }; }); services.AddTransient <IEmailSender, EmailSender>(); services.AddScoped <IService <ProductDTO>, ProductService>(); services.AddScoped <IService <CategoryDTO>, CategoryService>(); services.AddScoped <IService <BrandDTO>, BrandService>(); services.AddScoped <IService <StyleDTO>, StyleService>(); services.AddScoped <IService <AuthorDTO>, AuthorService>(); services.AddScoped <IService <TattooDTO>, TattooService>(); services.AddScoped <IService <CountryDTO>, CountryService>(); services.AddScoped <IService <AddressDTO>, AddressService>(); services.AddScoped <IService <OrderDTO>, OrderService>(); services.AddTransient <IGenericRepository <Brand>, BrandRepository>(); services.AddTransient <IGenericRepository <Product>, ProductRepository>(); services.AddTransient <IGenericRepository <Author>, AuthorRepository>(); services.AddTransient <IGenericRepository <Style>, StyleRepository>(); services.AddTransient <IGenericRepository <Category>, CategoryRepository>(); services.AddTransient <IGenericRepository <Tattoo>, TattooRepository>(); services.AddTransient <IGenericRepository <Country>, CountryRepository>(); services.AddTransient <IGenericRepository <Address>, AddressRepository>(); services.AddTransient <IGenericRepository <Order>, OrderRepository>(); services.AddScoped(sp => SessionBasket.GetBasket(sp)); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddMvc(); services.AddMemoryCache(); services.AddSession(); services.AddCors(); }
public static COrder CreateReserve(long agentId, long addressId, string comments) { try { Dictionary <string, string> res = new Dictionary <string, string>(); var basket = SessionBasket.GetBasket(); ArticleInfo[] prodInfo = new ArticleInfo[basket.Where(x => x.Key > 0).Count()]; int i = 0; foreach (var key in basket.Keys) { if (key > 0) { prodInfo[i] = new ArticleInfo(key, basket[key]); i++; } } DeliveryInfo delInfo = new DeliveryInfo(addressId, comments); Hashtable pars = new Hashtable(); pars["Articles"] = prodInfo; pars["Delivery"] = delInfo; //pars["AgentId"] = agentId; // agentid will be taken from session by the server! do not use this field! pars["ReserveOfficeId"] = 1; pars["ObtainMethod"] = "delivery"; // ownStorePickup, simplified_shipping - some magic hardcoded values in ultima2c.. //pars["ShippingAddress"] = address; COrder order = GetObject <COrder>("CreateReserve", pars); return(order); } catch (Exception ex) { SessionErrors.Add(ex); throw; } }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { //services.Configure<CookiePolicyOptions>(options => //{ // options.CheckConsentNeeded = context => true; // consent required // options.MinimumSameSitePolicy = SameSiteMode.None; //}); services.AddSession(opts => { opts.Cookie.IsEssential = true; // make the session cookie Essential }); services.AddScoped <Basket>(b => SessionBasket.GetBasket(b)); //??? services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); //??? services.AddDbContext <ApplicationDbContext>(opt => opt.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddTransient <IProductRep, ProductRep>(); services.AddTransient <IOrderRep, OrderRep>(); services.AddMemoryCache(); //??? services.AddSession(); services.AddMvc(); }
public static decimal GetDeliveryCost(long addressId) { try { Dictionary <string, string> res = new Dictionary <string, string>(); var basket = SessionBasket.GetBasket(); ArticleInfo[] prodInfo = new ArticleInfo[basket.Where(x => x.Key > 0).Count()]; int i = 0; foreach (var key in basket.Keys) { if (key > 0) { prodInfo[i] = new ArticleInfo(key, basket[key]); i++; } } DeliveryInfo delInfo = new DeliveryInfo(addressId, string.Empty); Hashtable pars = new Hashtable(); pars["Articles"] = prodInfo; pars["Delivery"] = delInfo; pars["ReserveOfficeId"] = 1; ValueValue order = GetObject <ValueValue>("GetDeliveryCost", pars); return(order.Value); } catch (Exception ex) { SessionErrors.Add(ex); throw ex; } }