public async Task SaveToDB(Note note) { using (this.context = new NotebookContext()) { context.Notes.Add(note); await context.SaveChangesAsync(); } }
public async Task <Note> ReadFromDB(int Id) { Note note; using (this.context = new NotebookContext()) { note = await this.context.Notes.FirstOrDefaultAsync(x => x.Id == Id); } return(note); }
public async Task SaveEditedToDB(Note note) { using (this.context = new NotebookContext()) { var editedNote = await context.Notes.FindAsync(note.Id); if (editedNote != null) { editedNote.Name = note.Name; editedNote.File = note.File; context.Entry(editedNote).State = EntityState.Modified; await context.SaveChangesAsync(); } } }
public async Task <List <BaseNote> > ReadFromDb() { return(await Task.Run(() => { List <BaseNote> listNotes = new List <BaseNote>(); using (this.context = new NotebookContext()) { var list = this.context.Notes.Select(x => x).ToList(); foreach (var item in list) { listNotes.Add(new BaseNote() { Id = item.Id, Name = item.Name }); } } return listNotes; })); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, NotebookContext dataContext) { dataContext.Database.Migrate(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/home/error"); } app.UseStaticFiles(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, NotebookContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseBrowserLink(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Notes}/{action=Index}/{id?}"); }); NotebookDbInitializer.Initialize(context); }
public ValuesController(NotebookContext context) { db = context; }
public CreateController(ILogger <CreateController> logger, NotebookContext context, IMapper mapper) { _logger = logger; _context = context; _mapper = mapper; }
public NotebookRepository(NotebookContext context) : base(context) { }
public NotesController() { dbContext = new NotebookContext(); // bellekte yer açıp tek bir yerde işlemleri yapmamızı sağlıyor // aksi takdirde yeni işlemler için her seferinde bellekte yer açmamız gerekir. }
public UserController(NotebookContext ctx) { this.dbContext = ctx; }
public ErrorReportRepository(NotebookContext notebookContext) { this.notebookContext = notebookContext; }
public UsersController(NotebookContext context) { db = context; }
public FileService(NotebookContext db) { this.db = db; }
internal BaseRepository(NotebookContext context) { _context = context; }
public UserService(NotebookContext db) { this.db = db; }
public AccountController(NotebookContext db) { this.db = db; }
public NotebookController(NotebookContext context) { _context = context; }
public DeleteController(NotebookContext context) { _context = context; }