public async Task <IActionResult> Edit(int id, [Bind("Id,EmployeeId,Created,Day,Message,Approved")] Timeoffrequest timeoffrequest)
        {
            if (id != timeoffrequest.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(timeoffrequest);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TimeoffrequestExists(timeoffrequest.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employee, "Id", "FullName", timeoffrequest.EmployeeId);
            return(View(timeoffrequest));
        }
        public async Task <IActionResult> ChangeStatus(string submit, [Bind("Id,EmployeeId,Created,Day,Message,Approved")] Timeoffrequest timeoffrequest)
        {
            try
            {
                switch (submit)
                {
                case "Approve":
                    timeoffrequest.Approved = true;
                    break;

                case "Deny":
                    timeoffrequest.Approved = false;
                    break;
                }
                _context.Update(timeoffrequest);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TimeoffrequestExists(timeoffrequest.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Create([Bind("Id,EmployeeId,Created,Day,Message,Approved")] Timeoffrequest timeoffrequest)
        {
            timeoffrequest.Created = DateTime.Now;
            if (HttpContext.Session.GetInt32("UserLoggedIn") == 1)
            {
                if (ModelState.IsValid)
                {
                    _context.Add(timeoffrequest);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(timeoffrequest));
            }
            else
            {
                return(RedirectToAction("Index", "Logins"));
            }
        }