예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,ComId,EmpId,FromDate,ToDate,LvDays,LeaveId,Remarks")] LeaveInput leaveInput)
        {
            if (id != leaveInput.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    leaveInput.ComId = session.GetString("ComSessionId");
                    _context.Update(leaveInput);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LeaveInputExists(leaveInput.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmpId"]   = new SelectList(_context.EmployeeInfo, "Id", "Name", leaveInput.EmpId);
            ViewData["LeaveId"] = new SelectList(_context.LeaveSetup, "Id", "Leavetype", leaveInput.LeaveId);
            return(View(leaveInput));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Id,ComId,EmpId,FromDate,ToDate,LvDays,LeaveId,Remarks")] LeaveInput leaveInput)
        {
            if (ModelState.IsValid)
            {
                leaveInput.ComId = session.GetString("ComSessionId");
                _context.Add(leaveInput);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmpId"]   = new SelectList(_context.EmployeeInfo, "Id", "Name", leaveInput.EmpId);
            ViewData["LeaveId"] = new SelectList(_context.LeaveSetup, "Id", "Leavetype", leaveInput.LeaveId);
            return(View(leaveInput));
        }