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));
        }
Beispiel #2
0
        // GET: Departments/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Department department = _departmentBusiness.GetById((int)id);

            if (department == null)
            {
                return(HttpNotFound());
            }
            return(View(department));
        }