public async Task <IActionResult> Create([Bind("Id,Code,Name")] County county) { if (ModelState.IsValid) { _context.Add(county); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(county)); }
public async Task <IActionResult> Create([Bind("Id,ItemType,Value")] LookUpData lookUpData) { if (ModelState.IsValid) { _context.Add(lookUpData); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(lookUpData)); }
public async Task <IActionResult> Create([Bind("Id,Name,CountyId")] SubCounty subCounty) { if (ModelState.IsValid) { _context.Add(subCounty); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CountyId"] = new SelectList(_context.County, "Id", "Name", subCounty.CountyId); return(View(subCounty)); }
public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,EmailAddress,PhoneNumber,DOB,GenderId,MaritalStatusId,SubCountyID")] Employee employee) { if (ModelState.IsValid) { _context.Add(employee); await _context.SaveChangesAsync(); 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)); }