Esempio n. 1
0
        public static void EditNote(string user_id, string name, string oldtext, string newtext)
        {
            NoteDbContext db   = new NoteDbContext();
            var           note = db.Notes.First(x => x.UserId == user_id && x.NoteName == name && x.NoteText == oldtext);

            note.NoteText = newtext;
            db.SaveChanges();
        }
Esempio n. 2
0
 static void Main(string[] args)
 {
     using (var db = new NoteDbContext())
     {
         db.Database.Migrate();
     }
     MvcEngine.Run(new WebServer.WebServer(8888, new ControllerRouter()));
 }
Esempio n. 3
0
        public static void RenameNote(string user_id, string noteoldname, string notenewname)
        {
            NoteDbContext db   = new NoteDbContext();
            var           note = db.Notes.First(x => x.UserId == user_id && x.NoteName == noteoldname);

            note.NoteName = notenewname;
            db.SaveChanges();
        }
Esempio n. 4
0
        public static void CreateNote(string user_id, string notename, string notetext)
        {
            NoteDbContext db = new NoteDbContext();

            db.Notes.Add(new NoteModel {
                UserId = user_id, NoteName = notename, NoteText = notetext
            });
            db.SaveChanges();
        }
 public bool Validate(string userName, string password)
 {
     using (var scope = _ServiceScopeFactory.CreateScope())
     {
         NoteDbContext context = scope.ServiceProvider.GetService <NoteDbContext>();
         BasicUser     user    = context.BasicUsers.Where(uu => uu.UserName == userName && uu.PassWord == password).FirstOrDefault();
         return(user != null);
     }
 }
Esempio n. 6
0
        // GET: Cards
        public ActionResult Index()
        {
            NoteDbContext notesdb = new NoteDbContext();
            var           darnita = notesdb.Categories.ToList();

            ViewBag.Categories = darnita;
            var blake = notesdb.Categories.ToList();

            return(View(blake));
        }
Esempio n. 7
0
        private static void InitDb()
        {
            NoteDbContext context = new NoteDbContext();

            if (false == context.Database.EnsureCreated())
            {
                SetupDb setupDb = new SetupDb(context);
                setupDb.Setup();
            }
        }
Esempio n. 8
0
        public static void DeleteNote(string id, string notename)
        {
            NoteDbContext db   = new NoteDbContext();
            var           note = db.Notes.First(x => x.UserId == id && x.NoteName == notename);

            if (note != null)
            {
                db.Notes.Remove(note);
            }
            db.SaveChanges();
        }
        public NotesServiceTest()
        {
            var optionsBuilder = new DbContextOptionsBuilder <NoteDbContext>();

            optionsBuilder.UseInMemoryDatabase("Testdatabase");

            _dbContext = new NoteDbContext(optionsBuilder.Options);
            _dbContext.Database.EnsureDeleted();

            _userSettingsServiceMock = new Mock <IUserSettingsService>();
        }
Esempio n. 10
0
        public static void DeleteAll(string user_id)
        {
            NoteDbContext db   = new NoteDbContext();
            var           note = db.Notes.Where(x => x.UserId == user_id).ToArray();

            if (note != null)
            {
                db.Notes.RemoveRange(note);
            }
            db.SaveChanges();
        }
Esempio n. 11
0
        private void confirm(object sender, EventArgs e)
        {
            Catagory_info info = new Catagory_info();

            info.Catagory_Nama = txt_title.Text;

            NoteDbContext context = new NoteDbContext();

            context.Catagory.Add(info);
            context.SaveChanges();
        }
Esempio n. 12
0
        public ActionResult Create(string Title, string Text, int Category)
        {
            NoteDbContext notesdb = new NoteDbContext();
            Note          silence = new Note();

            silence.Title    = Title;
            silence.Text     = Text;
            silence.Category = notesdb.Categories.Find(Category);
            notesdb.Notes.Add(silence);
            notesdb.SaveChanges();

            return(View());
        }
Esempio n. 13
0
        public IActionResult <AllUsernamesViewModel> Register(RegisterUserBindingModel registerUserBinding)
        {
            var user = new User
            {
                Username = registerUserBinding.Username,
                Password = registerUserBinding.Password
            };

            using (var context = new NoteDbContext())
            {
                context.Users.Add(user);
                context.SaveChanges();
            }

            return(this.All());
        }
Esempio n. 14
0
        public Main()
        {
            InitializeComponent();

            noteContext = new NoteDbContext();
            fileContext = new FileDbContext();

            InitNavigate();

            tree_Navi.MouseClick             += NoteOPerate;
            Main_Container.Panel2.MouseClick += MouseClick;
            btn_addFile.Click += addFile;
            btn_delFile.Click += delFile;

            btn_newNote.Click += newNote;
            btn_delNote.Click += delNote;
            btnSave.Click     += Save;
        }
Esempio n. 15
0
        public static NoteGetModel GetAll(string user_id)
        {
            NoteDbContext db     = new NoteDbContext();
            var           notes  = db.Notes.Where(x => x.UserId == user_id).ToArray();
            NoteGetModel  result = new NoteGetModel();

            result.NoteName = new string[notes.Length];
            result.NoteText = new string[notes.Length];
            if (notes.Length > 0)
            {
                for (int i = 0; i < notes.Length; i++)
                {
                    result.NoteName[i] = notes[i].NoteName;
                    result.NoteText[i] = notes[i].NoteText;
                }
            }
            return(result);
        }
Esempio n. 16
0
        public IActionResult <UserProfileModel> Profile(int id, NoteViewModel model)
        {
            using (var db = new NoteDbContext())
            {
                var note = new Note
                {
                    Title   = model.Title,
                    Content = model.Content,
                    UserId  = id
                };

                db.Notes.Add(note);
                db.SaveChanges();
            }


            return(this.Profile(id));
        }
Esempio n. 17
0
        public IActionResult <UserProfileModel> Profile(int id)
        {
            using (var context = new NoteDbContext())
            {
                var user = context.Users.Where(p => p.Id == id)
                           .Select(p => new UserProfileModel
                {
                    Id       = p.Id,
                    Username = p.Username,
                    Notes    = p.Notes.Select(k => new NoteViewModel()
                    {
                        Title   = k.Title,
                        Content = k.Content
                    })
                })
                           .SingleOrDefault();

                var viewModel = user;

                return(this.View(viewModel));
            }
        }
Esempio n. 18
0
        public IActionResult <AllUsernamesViewModel> All()
        {
            List <UsernameViewModel> usernames = new List <UsernameViewModel>();

            using (var context = new NoteDbContext())
            {
                var users = context.Users.Select(p => new UsernameViewModel
                {
                    Id       = p.Id,
                    Username = p.Username
                })
                            .ToList();

                usernames = users;
            }

            var model = new AllUsernamesViewModel
            {
                Usernames = usernames
            };


            return(this.View(model));
        }
Esempio n. 19
0
 public DashboardModel(NoteDbContext noteDbContext, ApplicationIdentityDbContext identityDbContext)
 {
     _noteDbContext     = noteDbContext;
     _identityDbContext = identityDbContext;
 }
 public Repository(NoteDbContext dbContext) => this.dbContext = dbContext;
Esempio n. 21
0
 public TagService(NoteDbContext dbContext)
 {
     _dbContext = dbContext;
 }
Esempio n. 22
0
 public TagController(NoteDbContext dbContext) => this.dbContext = dbContext;
 public NoteRepository(NoteDbContext context)
 {
     _context = context;
 }
 public NoteRepository(NoteDbContext db)
 {
     _db = db;
 }
 public UserRepository(NoteDbContext db)
 {
     _db = db;
 }
Esempio n. 26
0
 public NoteManager(NoteDbContext dbContext, ILogger <NoteManager> logger)
 {
     this._logger  = logger;
     this._context = dbContext;
     _logger.LogInformation(1, "created NoteManager");
 }
 public TestDataService(NoteDbContext db)
 {
     _db = db;
 }
Esempio n. 28
0
 public UserRepository(NoteDbContext context)
 {
     _context = context;
 }
Esempio n. 29
0
 public UnitOfWork(NoteDbContext context)
 {
     DbContext = context;
 }
Esempio n. 30
0
 public CommonDao()
 {
     db = new NoteDbContext();
 }