Esempio n. 1
0
        // remove access
        public IActionResult RemoveAccess(int id)
        {
            var employeeDataString = HttpContext.Session.GetString("employee");

            if (employeeDataString == "")
            {
                return(RedirectToAction("Login", "Auth"));
            }
            else
            {
                Employee employee = JsonConvert.DeserializeObject <Employee>(employeeDataString);

                if (userAccessManager.IsAccessExists(employee.Id, 4))
                {
                    if (userAccessManager.IsIdExists(id))
                    {
                        Models.UserAccess userAccess = userAccessManager.GetById(id);
                        userAccess.ActionBy   = employee.UserName;
                        userAccess.ActionTime = DateTime.Now.ToString("F");
                        userAccess.ActionDone = ActionAttributes.ActionRemove;
                        userAccess.State      = 0;

                        userAccessManager.Update(userAccess);

                        return(RedirectToAction("UserAccess", "Employee", new { id = userAccess.UserId }));
                    }
                    else
                    {
                        return(NotFound("404- Not Found"));
                    }
                }
                else
                {
                    return(NotFound("No Access"));
                }
            }
        }