88 lines
3.0 KiB
C#
88 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.OpenApi.Models;
|
|
using Moshaverino.Core.Models;
|
|
|
|
namespace Moshaverino.Core
|
|
{
|
|
public class Startup
|
|
{
|
|
public Startup(IConfiguration configuration)
|
|
{
|
|
Configuration = configuration;
|
|
}
|
|
|
|
//public static string baseAddress = "http://itrip-co.com";
|
|
public static string baseAddress = "http://localhost";
|
|
public IConfiguration Configuration { get; }
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddSwaggerGen(swagger =>
|
|
{
|
|
swagger.SwaggerDoc("v1", new OpenApiInfo
|
|
{
|
|
Title = "Moshaverino Api"
|
|
});
|
|
//swagger.IncludeXmlComments(Path.Combine(Directory.GetCurrentDirectory(), "DarvagApi.xml"));
|
|
});
|
|
services.AddControllers();
|
|
services.AddDbContext<MoshaverinoContext>(options =>
|
|
{
|
|
//options.UseSqlServer(Configuration.GetConnectionString("LocalConnection"));
|
|
options.UseSqlServer("Data Source=localhost;Initial Catalog=konkuric_moshaverino;Integrated Security=False;User ID=konkuric_dbadmin;Password=Amdemon@1377;Connect Timeout=15;Encrypt=False;Packet Size=4096");
|
|
});
|
|
services.AddScoped<DBInitializer>();
|
|
services.AddMvc(optione => optione.EnableEndpointRouting = false);
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
|
|
app.UseRouting();
|
|
app.UseSwagger();
|
|
app.UseStaticFiles();
|
|
app.UseDefaultFiles(new DefaultFilesOptions
|
|
{
|
|
DefaultFileNames = new
|
|
List<string> { "Index.chtml" }
|
|
});
|
|
app.UseSwaggerUI(c =>
|
|
{
|
|
|
|
c.SwaggerEndpoint($"{baseAddress}/swagger/v1/swagger.json", "iTRiP v1");
|
|
|
|
});
|
|
app.UseAuthorization();
|
|
|
|
app.UseMvc(routes =>
|
|
{
|
|
routes.MapRoute(
|
|
name: "default",
|
|
template: "{controller=Admin}/{action=Index}");
|
|
});
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
}
|
|
}
|
|
}
|