public ActionResult Detail(int Id)
        {
            var data     = new TaskDepartmentViewModel();
            var taskdata = itaskBusiness.GetTaskByDept(Id);

            if (taskdata != null)
            {
                data = (from task in db.Tasks
                        join dept in db.Departments on task.departmentId equals dept.departmentId
                        where dept.departmentId == Id /*&& task.Completed == 0*/
                        group task by task.Department.departmentname into g
                        select new TaskDepartmentViewModel
                {
                    departmentname = g.First().Department.departmentname,
                    BudgetedHours = g.Sum(s => s.BudgetedHours),
                    description = g.First().Department.description,
                    created_on = g.First().Department.created_on,
                    updated_on = g.First().Department.updated_on,
                    departmentId = g.First().Department.departmentId
                }).FirstOrDefault();
            }
            else
            {
                var Deptdata = idepartmentBusiness.GetById(Id);
                Mapper.Map(Deptdata, data);
                //data.departmentname = Deptdata.departmentname;
            }
            return(View(data));
        }
예제 #2
0
        public ActionResult GetTaskByDept(int id)
        {
            var TaskDetails = itaskBusiness.GetTaskByDept(id);

            return(Json(new
            {
                success = true,
                data = TaskDetails
            }));
        }