Пример #1
0
        // GET: ProductsServices/Edit/5
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var productService = await _bll.ProductsServices.FindAsync(id);

            if (productService == null)
            {
                return(NotFound());
            }

            var vm = new WebApp.ViewModels.ProductServiceCreateEditViewModel();

            vm.ProductService             = productService;
            vm.ProductForClientSelectList = new SelectList(
                await _bll.ProductsForClients.AllAsync(),
                nameof(BLL.App.DTO.ProductForClient.Id),
                nameof(BLL.App.DTO.ProductForClient.Product.ProductName));

            vm.WorkObjectSelectList = new SelectList(
                await _bll.WorkObjects.AllAsync(),
                nameof(BLL.App.DTO.WorkObject.Id),
                nameof(BLL.App.DTO.WorkObject.Client.CompanyAndAddress));

            return(View(vm));
        }
Пример #2
0
        public async Task <IActionResult> Edit(int id,
                                               WebApp.ViewModels.ProductServiceCreateEditViewModel vm)
        {
            if (id != vm.ProductService.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                _bll.ProductsServices.Update(vm.ProductService);
                await _bll.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            vm.ProductForClientSelectList = new SelectList(
                await _bll.ProductsForClients.AllAsync(),
                nameof(BLL.App.DTO.ProductForClient.Id),
                nameof(BLL.App.DTO.ProductForClient.Product.ProductName));

            vm.WorkObjectSelectList = new SelectList(
                await _bll.WorkObjects.AllAsync(),
                nameof(BLL.App.DTO.WorkObject.Id),
                nameof(BLL.App.DTO.WorkObject.Client.CompanyAndAddress));

            return(View(vm));
        }
Пример #3
0
        // GET: ProductsServices/Create
        public async Task <IActionResult> Create()
        {
            var vm = new WebApp.ViewModels.ProductServiceCreateEditViewModel();

            vm.ProductForClientSelectList = new SelectList(
                await _bll.ProductsForClients.AllAsync(),
                nameof(BLL.App.DTO.ProductForClient.Id),
                nameof(BLL.App.DTO.ProductForClient.Product.ProductName));

            vm.WorkObjectSelectList = new SelectList(
                await _bll.WorkObjects.AllAsync(),
                nameof(BLL.App.DTO.WorkObject.Id),
                nameof(BLL.App.DTO.WorkObject.Client.CompanyAndAddress));
            return(View(vm));
        }