public IActionResult AddNote(UserPlanner planner, string note)
        {
            planner.Notes = note;

            _context.UserPlanner.Add(planner);
            _context.SaveChanges();

            return(RedirectToAction("UserPlanner"));
        }
Exemple #2
0
 public UserController(IConfiguration _configuration)
 {
     configuration         = _configuration;
     loginAuthHelper       = new LoginAuthHelper(configuration);
     userPlanner           = new UserPlanner();
     userLoginPlanner      = new UserLoginPlanner();
     userTokenPlanner      = new UserTokenPlanner();
     tokenBlackListPlanner = new TokenBlackListPlanner();
     userProfilePlanner    = new UserProfilePlanner();
 }
 public IActionResult RemovePlanner(UserPlanner userPlanner)
 {
     if (userPlanner != null)
     {
         _context.UserPlanner.Remove(userPlanner);
         _context.SaveChanges();
         return(RedirectToAction("UserPlanner"));
     }
     return(RedirectToAction("UserPlanner"));
 }
        public IActionResult UpdateNote(int Id)
        {
            UserPlanner found = _context.UserPlanner.Find(Id);

            if (found != null)
            {
                return(View(found));
            }
            else
            {
                return(RedirectToAction("UserPlanner"));
            }
        }
        public IActionResult UpdateNote(UserPlanner updatedNote)
        {
            UserPlanner found = _context.UserPlanner.Find(updatedNote.UserId);

            if (ModelState.IsValid && found != null)
            {
                found.UserId = updatedNote.UserId;
                found.Notes  = updatedNote.Notes;

                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.Update(found);
                _context.SaveChanges();

                return(RedirectToAction("UserPlanner"));
            }
            return(View("UpdateNote", found));
        }
        public IActionResult EditNote(int Id, string note)
        {
            UserPlanner found = _context.UserPlanner.Find(Id);

            if (ModelState.IsValid && note != null)
            {
                found.Notes = note;

                _context.Entry(found).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                _context.UserPlanner.Update(found);
                _context.SaveChanges();
                return(RedirectToAction("UserPlanner"));
            }
            else
            {
                return(RedirectToAction("UserPlanner"));
            }
        }
        public IActionResult AddFavorite(Datum datum)
        {
            AspNetUsers thisUser    = _context.AspNetUsers.Where(u => u.UserName == User.Identity.Name).First();
            UserPlanner userPlanner = new UserPlanner();

            if (ModelState.IsValid)
            {
                userPlanner.UserId      = thisUser.Id;
                userPlanner.Restaurants = datum.restaurant_name;
                userPlanner.Dates       = TempData["dayy"].ToString();
                userPlanner.Notes       = null;
                userPlanner.Weather     = TempData["weather"].ToString();
                userPlanner.Events      = TempData["weatherSum"].ToString();

                _context.UserPlanner.Add(userPlanner);
                _context.SaveChanges();
                return(RedirectToAction("UserPlanner", userPlanner));
            }

            return(RedirectToAction("RestaurantSearch", "XYZ"));
        }
 public BusinessTest()
 {
     userLoginPlanner = new UserPlanner();
 }
 public IActionResult AddNote(UserPlanner users)
 {
     return(View(users));
 }