Esempio n. 1
0
 public async Task SaveToDB(Note note)
 {
     using (this.context = new NotebookContext())
     {
         context.Notes.Add(note);
         await context.SaveChangesAsync();
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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();
                }
            }
        }
Esempio n. 4
0
 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?}");
            });
        }
Esempio n. 6
0
        // 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;
 }
Esempio n. 8
0
 public CreateController(ILogger <CreateController> logger, NotebookContext context, IMapper mapper)
 {
     _logger  = logger;
     _context = context;
     _mapper  = mapper;
 }
Esempio n. 9
0
 public NotebookRepository(NotebookContext context) : base(context)
 {
 }
Esempio n. 10
0
 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;
 }
Esempio n. 12
0
 public ErrorReportRepository(NotebookContext notebookContext)
 {
     this.notebookContext = notebookContext;
 }
 public UsersController(NotebookContext context)
 {
     db = context;
 }
Esempio n. 14
0
 public FileService(NotebookContext db)
 {
     this.db = db;
 }
 internal BaseRepository(NotebookContext context)
 {
     _context = context;
 }
Esempio n. 16
0
 public UserService(NotebookContext db)
 {
     this.db = db;
 }
 public AccountController(NotebookContext db)
 {
     this.db = db;
 }
 public NotebookController(NotebookContext context)
 {
     _context = context;
 }
Esempio n. 19
0
 public DeleteController(NotebookContext context)
 {
     _context = context;
 }