//GET: /Admin/Task
        public ActionResult Task(string name)
        {
            if (!(User.Identity.IsAuthenticated && User.Identity.Name == "admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.Operation = name;
            if (name == "Edit")
            {
                List <Tasks>         tasks          = TasksDAL.GetAllTasks();
                List <TaskViewModel> tasksViewModel = new List <TaskViewModel>();

                foreach (var task in tasks)
                {
                    tasksViewModel.Add(
                        new TaskViewModel(task)
                        );
                }
                return(View(tasksViewModel));
            }
            else
            {
                List <Users>         users          = UsersDAL.GetAllUsers();
                List <UserViewModel> usersViewModel = new List <UserViewModel>();

                foreach (var user in users)
                {
                    usersViewModel.Add(
                        new UserViewModel(user)
                        );
                }
                return(View(usersViewModel));
            }
        }
示例#2
0
 public static DataTable GetAllTasks()
 {
     return(TasksDAL.GetAllTasks());
 }