Example #1
0
        public async Task <IActionResult> Create([Bind("PersonId,UserId,Password,DepartmentName")] Person person)
        {
            if (ModelState.IsValid)
            {
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
        public async Task <IActionResult> Register([Bind("BookId,Title,Writer,Company,Price,Buydate,ManagementDepartment")] Book book)
        {
            if (ModelState.IsValid)
            {
                book.Updatedate = DateTime.Now;
                book.PersonId   = (int)HttpContext.Session.GetInt32("PersonId");
                _context.Add(book);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PersonId"] = new SelectList(_context.Person, "PersonId", "PersonId", book.PersonId);
            return(View(book));
        }