Пример #1
0
        // GET: Tasks/Details/5
        public ActionResult Details(int id)
        {
            var item = unitOfWork.TasksRepository.GetByID(id);
            var vm   = TaskMapper.MapItemToViewModel(item);

            return(View(item));
        }
Пример #2
0
        // GET: Tasks
        public ActionResult Index()
        {
            var items   = unitOfWork.TasksRepository.Get();
            var vmItems = TaskMapper.MapItemToViewModel(items);

            return(View(vmItems));
        }
Пример #3
0
        public ActionResult Appointments()
        {
            //var model = AppointMapper.MapAllItemsToViewModel(
            //    unitOfWork.ResInTasksRepository.Get(includeProperties: "Resource,Task"),
            //    unitOfWork.ResourcesRepository.Get());

            var model = new List <AppointViewModel>();
            var rits  = unitOfWork.ResInTasksRepository.Get(includeProperties: "Resource,Task");

            foreach (var item in rits.GroupBy(rit => rit.task_id).Select(g => g.First()))
            {
                IEnumerable <ResourceInTaskVM> resources = rits.Where(rit => rit.task_id == item.task_id).Select(x => AppointMapper.MapItemToViewModel(x)).ToList();
                model.Add(new AppointViewModel
                {
                    Task         = TaskMapper.MapItemToViewModel(item.Task),
                    Resources    = resources.ToList(),
                    AllResources = ResourceMapper.MapItemToViewModel(unitOfWork.ResourcesRepository.Get().Where(r => !resources.Any(vm => vm.Resource.Id == r.resource_id)))
                });
            }

            return(View(model));
        }
Пример #4
0
        public ActionResult Appoint(int id)
        {
            AppointViewModel model = new AppointViewModel();

            model.Task = TaskMapper.MapItemToViewModel(unitOfWork.TasksRepository.GetByID(id));

            var rits = unitOfWork.ResInTasksRepository.Get(x => x.task_id == id, includeProperties: "Resource,Task");

            if (rits != null)
            {
                model.Resources = AppointMapper.MapItemsToViewModel(rits);
            }
            else
            {
                model.Resources = new List <ResourceInTaskVM>();
            }

            model.AllResources = ResourceMapper.MapItemToViewModel(unitOfWork.ResourcesRepository.Get()
                                                                   .Where(r => !model.Resources.Any(vm => vm.Resource.Id == r.resource_id)));

            return(PartialView("_Appoint", model));
        }
Пример #5
0
        // GET: Tasks/Edit/5
        public ActionResult Edit(int id)
        {
            var model = TaskMapper.MapItemToViewModel(unitOfWork.TasksRepository.GetByID(id));

            return(View(model));
        }
Пример #6
0
        public ActionResult EditPartial(int id)
        {
            TaskViewModel model = TaskMapper.MapItemToViewModel(unitOfWork.TasksRepository.GetByID(id));

            return(PartialView("_Edit", model));
        }