public async Task <IActionResult> Edit(int id, [Bind("Id,EmpId,SalaryId")] MonthsSalary monthsSalary) { if (id != monthsSalary.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(monthsSalary); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MonthsSalaryExists(monthsSalary.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["EmpId"] = new SelectList(_context.EmpInfo, "Id", "Address", monthsSalary.EmpId); ViewData["SalaryId"] = new SelectList(_context.Salary, "Id", "Id", monthsSalary.SalaryId); return(View(monthsSalary)); }
public async Task <IActionResult> Create([Bind("Id,EmpId,SalaryId")] MonthsSalary monthsSalary) { if (ModelState.IsValid) { _context.Add(monthsSalary); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["EmpId"] = new SelectList(_context.EmpInfo, "Id", "Address", monthsSalary.EmpId); ViewData["SalaryId"] = new SelectList(_context.Salary, "Id", "Id", monthsSalary.SalaryId); return(View(monthsSalary)); }