public bool Add(Theme theme) { try { _manager.Themes.Add(theme); _manager.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public bool Add(Film film) { try { _manager.Films.Add(film); _manager.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
public bool Add(User user) { try { _manager.Users.Add(user); _manager.SaveChanges(); return(true); } catch (Exception e) { return(false); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ApiReactContext context) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } //context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //Création de la BdD if (!context.Users.Any()) { context.Users.Add(new DAL.Models.User() { Login = "******", Password = "******" }); context.SaveChanges(); } app.UseAuthentication(); // Vérification de l'authentification // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS, etc.), // specifying the Swagger JSON endpoint. app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); app.UseStaticFiles(); app.UseMvc(); }