示例#1
0
        public async Task <IActionResult> Create([Bind("Id,Name")] Role role)
        {
            if (ModelState.IsValid)
            {
                _context.Add(role);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(role));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Address,City,State,Phone")] Contact contact)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contact);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(contact));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,EmployeeId,Hours,Reason")] PTORequest pTORequest)
        {
            if (ModelState.IsValid)
            {
                _context.Add(pTORequest);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "Id", "Id", pTORequest.EmployeeId);
            return(View(pTORequest));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,FirstName,LastName,PTO,RoleId,ContactId,ClockedIn")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContactId"] = new SelectList(_context.Contacts, "Id", "Id", employee.ContactId);
            ViewData["RoleId"]    = new SelectList(_context.Roles, "Id", "Id", employee.RoleId);
            return(View(employee));
        }
示例#5
0
        //WIP: this method will create a new request from the logged in user. WORRY ABOUT ERROR HANDLING LATER
        public async Task <IActionResult> AddRequest(Employee employee, int hours, string reason)
        {
            employee = _context.Employees.Where(emp => emp.Id == 33).FirstOrDefault();     //PLACEHOLDER VALUE FOR FUTURE LOGGED IN USER****
            if (employee.Id == 0 || employee == null)
            {
                PTORequest newRequest = new PTORequest
                {
                    Employee = employee,     //not sure if this can be passed as an employee object from the view
                    Hours    = hours,
                    Reason   = reason,
                    Status   = _context.Statuses.Where(stat => stat.Name == "In Process").FirstOrDefault()
                };

                _context.Add(newRequest);
                await _context.SaveChangesAsync();     //comment this line for front-end testing (aka: comment to not flood db)

                return(RedirectToAction("Main", "Home"));
            }
            return(RedirectToAction("Index"));
        }
示例#6
0
        public async Task <IActionResult> EditEmployee(int id, [Bind("Id,FirstName,LastName,PTO,RoleId,ContactId,ClockedIn")] Employee employee) //rename this method
        {
            if (employee.Id != id)
            {
                return(NotFound());
            }
            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                }
            }

            return(RedirectToAction("ManageEmployee"));
        }