public int AddVersion(VersionModel version) { using (Version <VersionModel> v = new Version <VersionModel>(_file)) { var result = v.AddVersion(version); //v.Commit(); return(result); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer( Configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Transient); services.AddCors(options => { options.AddDefaultPolicy( builder => { builder.WithOrigins(AcceptRoute); }); }); services.AddIdentity <AppUser, AppRole>(options => { options.Password.RequiredLength = 3; options.Password.RequiredUniqueChars = 3; options.Password.RequireDigit = false; options.Password.RequireNonAlphanumeric = false; }).AddEntityFrameworkStores <ApplicationDbContext>(); services.AddScoped <IUnitOfWork, UnitOfWork>(); services.AddAutoMapper(typeof(VnpostMappings)); Version.AddVersion(services); var appSettingsSection = Configuration.GetSection("AppSettings"); services.Configure <AppSettings>(appSettingsSection); var appSettings = appSettingsSection.Get <AppSettings>(); var key = Encoding.ASCII.GetBytes(appSettings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false, }; }); services.AddControllers(); }