Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("DepartmentNo,DepartmentName,DepartmentLocation")] DepartmentPoco department)
        {
            if (id != department.DepartmentNo)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await service.Update(department);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartmentExists(department.DepartmentNo))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("DepartmentNo,DepartmentName,DepartmentLocation")] DepartmentPoco department)
        {
            if (ModelState.IsValid)
            {
                await service.Add(department);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(department));
        }