Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("BuildingId,Name")] Building building)
        {
            if (ModelState.IsValid)
            {
                _context.Add(building);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(building));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,DepartmentId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DepartmentId"] = new SelectList(_context.Set <Department>(), "DepartmentId", "Name", employee.DepartmentId);
            return(View(employee));
        }
        public async Task <IActionResult> Create([Bind("DepartmentId,Name,BuildingId")] Department department)
        {
            if (ModelState.IsValid)
            {
                _context.Add(department);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BuildingId"] = new SelectList(_context.Set <Building>(), "BuildingId", "Name", department.BuildingId);
            return(View(department));
        }