public void PreparingData()
        {
            var listPriority = new List <dynamic>()
            {
                new
                {
                    Name  = Priority.High.GetDescription(),
                    Value = (byte)Priority.High
                },
                new
                {
                    Name  = Priority.Normal.GetDescription(),
                    Value = (byte)Priority.Normal
                },
                new
                {
                    Name  = Priority.Low.GetDescription(),
                    Value = (byte)Priority.Low
                },
            };

            ViewBag.Priorities  = listPriority;
            ViewBag.Departments = DepartmentBO.GetAll();
            ViewBag.Projects    = ProjectBO.GetAll();
        }
        //
        // GET: /Task/

        public ActionResult Index(TasksSearchModel searchModel)
        {
            var listTasks = new List <TasksDisplayModel>();

            if (searchModel == null)
            {
                searchModel = new TasksSearchModel
                {
                    StartDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToString(Helper.FormatDate),
                    EndDate   = new DateTime(DateTime.Now.Year, DateTime.Now.Month + 1, 1).AddDays(-1).ToString(Helper.FormatDate),
                };
            }
            DateTime sdate;
            DateTime edate;

            DateTime.TryParseExact(searchModel.StartDate, Helper.FormatDate,
                                   new CultureInfo("en-US"),
                                   DateTimeStyles.None,
                                   out sdate);
            DateTime.TryParseExact(searchModel.EndDate, Helper.FormatDate,
                                   new CultureInfo("en-US"),
                                   DateTimeStyles.None,
                                   out edate);

            var departments = new List <Department> {
                new Department {
                    UserId = 0, Name = "--- All ---"
                }
            };

            departments.AddRange(DepartmentBO.GetAll());
            ViewBag.Departments = departments;

            var projects = new List <Project> {
                new Project {
                    Id = 0, Name = "--- All ---"
                }
            };

            projects.AddRange(ProjectBO.GetAll());
            ViewBag.Projects = projects;

            var tasks = TaskBO.Search(searchModel.Name, searchModel.Leader, sdate, edate);

            foreach (var item in tasks)
            {
                var department = DepartmentBO.GetById(item.Leader);
                var project    = ProjectBO.GetById(item.ProjectId);
                var model      = new TasksDisplayModel
                {
                    Id          = item.Id,
                    ProjectId   = item.ProjectId,
                    ProjectName = project.Name,
                    Name        = item.Name,
                    Description = item.Description,
                    Leader      = item.Leader,
                    LeaderName  = department.Name,
                    Priority    = item.Priority,
                    StartDate   = item.StartDate,
                    EndDate     = item.EndDate,
                    User        = UserBO.GetById(item.Leader),
                    CreatedDate = item.CreateDate == null ? string.Empty : ((DateTime)item.CreateDate).ToString(Helper.FormatDate),
                };

                if (CurrentUser.IsManager || CurrentUser.DepartmentLeader == item.Leader)
                {
                    listTasks.Add(model);
                }
            }
            searchModel.Tasks = listTasks;
            return(View(searchModel));
        }