Пример #1
0
        public async Task <ViewResult> Create(int?taskId, int?designId)
        {
            DesignSupplyRequest viewModel = new DesignSupplyRequest
            {
                ComponentId = designId ?? 0,
                DesiredDate = DateTime.Now
            };

            if (taskId.HasValue)
            {
                viewModel.TaskId = taskId;
                ViewBag.Designs  = (await _taskService.GetByIdAsync(viewModel.TaskId.Value)).ObtainedDesigns
                                   .Select(c => new SelectListItem(
                                               _designService.GetByIdAsync(c.ComponentId).Result.ToString(),
                                               c.ComponentId.ToString()
                                               )).AsEnumerable();
            }
            else
            {
                ViewBag.Designs = (await _designService.GetAllAsync())
                                  .Select(c => new SelectListItem(c.ToString(), c.Id.ToString())).AsEnumerable();
            }

            return(View(viewModel));
        }
        public async Task <IActionResult> GetPartialViewForDeviceItem(string type, int index)
        {
            if (type.ToLower() == "montage")
            {
                DeviceItem <Montage> viewModelMontage = new DeviceItem <Montage>()
                {
                    Id                  = index,
                    Component           = new MontageInDevice(),
                    AllComponents       = await _montageService.GetAllAsync(),
                    SelectedComponentId = 0
                };
                return(PartialView("Partail/Device/Montageitem", viewModelMontage));
            }

            DeviceItem <Design> viewModelDesign = new DeviceItem <Design>()
            {
                Id                  = index,
                Component           = new DesignInDevice(),
                AllComponents       = await _designService.GetAllAsync(),
                SelectedComponentId = 0
            };

            return(PartialView("Partail/Device/DesignItem", viewModelDesign));
        }