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