Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Name")] County county)
        {
            if (id != county.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(county);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CountyExists(county.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(county));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,ItemType,Value")] LookUpData lookUpData)
        {
            if (id != lookUpData.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(lookUpData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LookUpDataExists(lookUpData.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(lookUpData));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,CountyId")] SubCounty subCounty)
        {
            if (id != subCounty.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(subCounty);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SubCountyExists(subCounty.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountyId"] = new SelectList(_context.County, "Id", "Name", subCounty.CountyId);
            return(View(subCounty));
        }
Example #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,FirstName,LastName,EmailAddress,PhoneNumber,DOB,GenderId,MaritalStatusId,SubCountyID")] Employee employee)
        {
            if (id != employee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            var LookUpData    = _context.LookUpData;
            var MaritalStatus = LookUpData.Where(b => b.ItemType == ItemType.MaritalStatus).ToList();
            var Gender        = LookUpData.Where(b => b.ItemType == ItemType.Gender).ToList();

            ViewData["GenderId"]        = new SelectList(Gender, "Id", "Value", employee.GenderId);
            ViewData["MaritalStatusId"] = new SelectList(MaritalStatus, "Id", "Value", employee.MaritalStatusId);
            ViewData["CountyID"]        = new SelectList(_context.County, "Id", "Name", employee.SubCounty.County.Id);
            ViewData["SubCountyID"]     = new SelectList(_context.SubCounty, "Id", "Name", employee.SubCountyID);
            return(View(employee));
        }