Esempio n. 1
0
        public async Task <ActionResult> Create([Bind(Include = "AddressId,Address1,Address2,City,PostalCode")] EmployeeAddress employeeAddress)
        {
            if (ModelState.IsValid)
            {
                db.EmployeeAddresses.Add(employeeAddress);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(employeeAddress));
        }
        public async Task <ActionResult> Create([Bind(Include = "EmpId,FirstName,LastName,Phone,EmailID,AddressID")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.AddressID = new SelectList(db.EmployeeAddresses, "AddressId", "Address1", employee.AddressID);
            return(View(employee));
        }