You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Startup.cs 3.6KB

1 year ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. using Karsha_Site.Application.Interfaces.Contexts;
  2. using Karsha_Site.Application.Interfaces.FacadPatterns;
  3. using Karsha_Site.Application.Services.Common.Queries.GetCategory;
  4. using Karsha_Site.Application.Services.Common.Queries.GetCustomer;
  5. using Karsha_Site.Application.Services.Common.Queries.GetMenuItem;
  6. using Karsha_Site.Application.Services.Costomers.Commands.EditCustomers;
  7. using Karsha_Site.Application.Services.Costomers.Commands.InsetCustomers;
  8. using Karsha_Site.Application.Services.Costomers.Commands.RemoveCustomers;
  9. using Karsha_Site.Application.Services.Costomers.Queries.GetCustomers;
  10. using Karsha_Site.Application.Services.Products.FacadPattern;
  11. using Karsha_Site.Persistance.Contexts;
  12. using Microsoft.AspNetCore.Builder;
  13. using Microsoft.AspNetCore.Hosting;
  14. using Microsoft.AspNetCore.HttpsPolicy;
  15. using Microsoft.CodeAnalysis.Options;
  16. using Microsoft.EntityFrameworkCore;
  17. using Microsoft.Extensions.Configuration;
  18. using Microsoft.Extensions.DependencyInjection;
  19. using Microsoft.Extensions.Hosting;
  20. using System;
  21. using System.Collections.Generic;
  22. using System.Linq;
  23. using System.Threading.Tasks;
  24. namespace EndPoint.Site
  25. {
  26. public class Startup
  27. {
  28. public Startup(IConfiguration configuration)
  29. {
  30. Configuration = configuration;
  31. }
  32. public IConfiguration Configuration { get; }
  33. // This method gets called by the runtime. Use this method to add services to the container.
  34. public void ConfigureServices(IServiceCollection services)
  35. {
  36. services.AddScoped<IDataBaseContext, DataBaseContext>();
  37. services.AddScoped<IGetAboutAddressServise, GetAboutAddressServise>();
  38. services.AddScoped<IInsertCustomersServise, InsertCustomersServise>();
  39. services.AddScoped<IEditCustomersService, EditCustomersService>();
  40. services.AddScoped<IRemoveCategoriesService, RemoveCustomerService>();
  41. services.AddScoped<IProductFacad, ProductFacad>();
  42. services.AddScoped<IGetMenuItemService, GetMenuItemService>();
  43. services.AddScoped<IGetCategoryService, GetCategoryService>();
  44. services.AddScoped<IGetCustomerService, GetCustomerService>();
  45. string connectionString = "Data Source=.; Initial Catalog = " +
  46. "Karsha; User id=sa;Password=1;";
  47. services.AddEntityFrameworkSqlServer().AddDbContext<DataBaseContext>(option => option.UseSqlServer(connectionString));
  48. services.AddControllersWithViews();
  49. }
  50. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  51. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  52. {
  53. if (env.IsDevelopment())
  54. {
  55. app.UseDeveloperExceptionPage();
  56. }
  57. else
  58. {
  59. app.UseExceptionHandler("/Home/Error");
  60. // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
  61. app.UseHsts();
  62. }
  63. app.UseHttpsRedirection();
  64. app.UseStaticFiles();
  65. app.UseRouting();
  66. app.UseAuthorization();
  67. app.UseEndpoints(endpoints =>
  68. {
  69. endpoints.MapControllerRoute(
  70. name: "default",
  71. pattern: "{controller=Home}/{action=Index}/{id?}");
  72. endpoints.MapControllerRoute(
  73. name: "areas",
  74. pattern: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
  75. );
  76. });
  77. }
  78. }
  79. }