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(); }
static void Main(string[] args) { using (var db = new NoteDbContext()) { db.Database.Migrate(); } MvcEngine.Run(new WebServer.WebServer(8888, new ControllerRouter())); }
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(); }
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); } }
// 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)); }
private static void InitDb() { NoteDbContext context = new NoteDbContext(); if (false == context.Database.EnsureCreated()) { SetupDb setupDb = new SetupDb(context); setupDb.Setup(); } }
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>(); }
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(); }
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(); }
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()); }
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()); }
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; }
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); }
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)); }
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)); } }
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)); }
public DashboardModel(NoteDbContext noteDbContext, ApplicationIdentityDbContext identityDbContext) { _noteDbContext = noteDbContext; _identityDbContext = identityDbContext; }
public Repository(NoteDbContext dbContext) => this.dbContext = dbContext;
public TagService(NoteDbContext dbContext) { _dbContext = dbContext; }
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; }
public NoteManager(NoteDbContext dbContext, ILogger <NoteManager> logger) { this._logger = logger; this._context = dbContext; _logger.LogInformation(1, "created NoteManager"); }
public TestDataService(NoteDbContext db) { _db = db; }
public UserRepository(NoteDbContext context) { _context = context; }
public UnitOfWork(NoteDbContext context) { DbContext = context; }
public CommonDao() { db = new NoteDbContext(); }