예제 #1
0
        public async Task <IActionResult> Create([Bind("Id,Title,ReleaseDate,Genre,Price")] Movie movie)
        {
            if (ModelState.IsValid)
            {
                _context.Add(movie);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(movie));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,Title,Date,Importance,Content,Deadline,ID_User")] ToDo toDo)
        {
            var current_User = UserManager.GetUserAsync(HttpContext.User).Result;

            if (null != current_User)
            {
                if (ModelState.IsValid)
                {
                    toDo.User = current_User;
                    _context.Add(toDo);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(toDo));
            }
            return(View("ErreurPasConnecte"));
        }