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