Beispiel #1
0
 public LoginVM()
 {
     context         = new NoteAppContext();
     User            = new User();
     RegisterCommand = new RegisterCommand(this);
     LoginCommand    = new LoginCommand(this);
 }
Beispiel #2
0
        public IActionResult <UserProfileViewModel> Profile(NoteAddBindingModel noteBindingModel)
        {
            UserProfileViewModel vm = null;

            using (NoteAppContext context = new NoteAppContext())
            {
                User user = context.Users.Include("Notes").SingleOrDefault(u => u.Id == noteBindingModel.UserId);
                user.Notes.Add(new Note()
                {
                    Title = noteBindingModel.Title, Content = noteBindingModel.Content
                });

                context.SaveChanges();

                vm = new UserProfileViewModel()
                {
                    UserId   = noteBindingModel.UserId,
                    Username = user.Username,
                    Notes    = user.Notes.Select(n => new NoteViewModel()
                    {
                        Title = n.Title, Content = n.Content
                    }).ToArray(),
                };
            }

            return(this.View(vm));
        }
 public void AdicionarNota(NotesSet note)
 {
     using (var conexao = new NoteAppContext())
     {
         conexao.Note.Add(note);
         conexao.SaveChanges();
     }
 }
 public NotesSet ListarUmaNota(int id)
 {
     using (var conexao = new NoteAppContext())
     {
         return(conexao.Note
                .Where(x => x.ID == id)
                .FirstOrDefault());
     }
 }
        public List <NotesSet> ListarNotas()
        {
            using (var conexao = new NoteAppContext())
            {
                var listaNotas = conexao.Note.ToList();

                return(listaNotas);
            }
        }
 public void RemoverNota(int id)
 {
     using (var conexao = new NoteAppContext())
     {
         var note = new NotesSet {
             ID = id
         };
         conexao.Note.Attach(note);
         conexao.Note.Remove(note);
         conexao.SaveChanges();
     }
 }
Beispiel #7
0
 public NotesVM()
 {
     IsEditing      = false;
     context        = new NoteAppContext();
     NewNotebookCmd = new NewNotebookCommand(this);
     NewNoteCmd     = new NewNoteCommand(this);
     BeginEditCmd   = new BeginEditCommand(this);
     HasEditedCmd   = new HasEditedCommand(this);
     Notebooks      = new ObservableCollection <Notebook>();
     Notes          = new ObservableCollection <Note>();
     ReadNotebooks();
     ReadNotes();
 }
Beispiel #8
0
        public IActionResult Register(UserRegisterBindingModel model)
        {
            using (NoteAppContext context = new NoteAppContext())
            {
                context.Users.Add(new User()
                {
                    Username = model.Username, Password = $"SECRET{model.Password}"
                });
                context.SaveChanges();
            }

            return(this.View("Home", "Index"));
        }
 public void AtualizarNote(NotesSet note)
 {
     using (var conexao = new NoteAppContext())
     {
         var result = conexao.Note.SingleOrDefault(b => b.ID == note.ID);
         if (result != null)
         {
             result.CH_Name        = note.CH_Name;
             result.CH_Description = note.CH_Description;
             result.DT_Creation    = note.DT_Creation;
             conexao.SaveChanges();
         }
     }
 }
Beispiel #10
0
        public IActionResult <UserAllViewModel> All()
        {
            UserAllViewModel vm = null;

            using (NoteAppContext context = new NoteAppContext())
            {
                vm = new UserAllViewModel()
                {
                    Users = context.Users.Select(u => new UserSimpleViewModel()
                    {
                        Id = u.Id, Username = u.Username
                    }).ToList()
                };
            }

            return(this.View(vm));
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new NoteAppContext(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <NoteAppContext> >())) {
                // Look for any notes.
                if (context.Note.Any())
                {
                    return;   // DB has been seeded
                }

                context.Note.AddRange(
                    new Note {
                    Title    = "IT 372 Midterm",
                    Contents = "Midterms coming up! Study time - review slides and reading. The test is on paper. Prepare early.",
                    DueDate  = DateTime.Parse("2019-11-1"),
                },

                    new Note {
                    Title    = "Biology Lab 3",
                    Contents = "Lab on Mitosis and Meiosis. Located on Main Campus, Room 301. Professor said to bring paper and pen to record the lab results. Remember to bring an apron.",
                    DueDate  = DateTime.Parse("2019-11-12"),
                },

                    new Note {
                    Title    = "Return library books",
                    Contents = "Borrowed a few books to learn more about aquatic life. Need to return by this date or get a $5.00 fine for each book. Do not forget!",
                    DueDate  = DateTime.Parse("2019-11-15"),
                },

                    new Note {
                    Title    = "Scholarship Banquet",
                    Contents = "RSVP for the banquet. Let my plus-one know about the date, time, and location. Business attire.",
                    DueDate  = DateTime.Parse("2019-11-20"),
                },

                    new Note {
                    Title    = "Software Development Lifecycle",
                    Contents = "Requirements > Analysis > Implementation > Verification > Maintenance (the longest, and most costly stage)"
                }
                    );
                context.SaveChanges();
            }
        }
Beispiel #12
0
        public IActionResult <UserProfileViewModel> Profile(int id)
        {
            UserProfileViewModel vm = null;

            using (NoteAppContext context = new NoteAppContext())
            {
                User user = context.Users.Include("Notes").SingleOrDefault(u => u.Id == id);
                vm = new UserProfileViewModel()
                {
                    UserId   = id,
                    Username = user.Username,
                    Notes    = user.Notes.Select(n => new NoteViewModel()
                    {
                        Title = n.Title, Content = n.Content
                    }).ToArray(),
                };
            }

            return(this.View(vm));
        }
Beispiel #13
0
 public NoteListsController(NoteAppContext context)
 {
     _context = context;
 }
 public NoteBooksController(NoteAppContext context)
 {
     _context = context;
 }