Example #1
0
        public IActionResult Register(RegisterViewModel model)
        {
            var user = new User()
            {
                Username = model.Username,
                Password = model.Password
            };

            using (var db = new SimpleMvcFrameworkDbContext())
            {
                db.Users.Add(user);
                db.SaveChanges();
            }

            return(View());
        }
Example #2
0
        public IActionResult <UserProfileViewModel> Profile(AddNoteViewModel model)
        {
            using (var db = new SimpleMvcFrameworkDbContext())
            {
                var user = db.Users.Find(model.UserId);
                //var user = db.Users.FirstOrDefault(u => u.Id == model.UserId);
                var note = new Note()
                {
                    Title   = model.Title,
                    Content = model.Content
                };

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

            return(Profile(model.UserId));
        }