Пример #1
0
        public async Task <PartialViewResult> CreateOrUpdateModal(long?id = null)
        {
            IProductAppService     productAppService = this._productAppService;
            NullableIdInput <long> nullableIdInput   = new NullableIdInput <long>()
            {
                Id = id
            };
            CreateOrUpdateProductModalViewModel createOrUpdateProductModalViewModel = new CreateOrUpdateProductModalViewModel(await productAppService.GetProductForEdit(nullableIdInput));

            if (!id.HasValue)
            {
                createOrUpdateProductModalViewModel.CanMakeActive = new bool?(false);
            }
            else
            {
                IPriceAppService      priceAppService       = this._priceAppService;
                GetProductPricesInput getProductPricesInput = new GetProductPricesInput()
                {
                    ProductId = id.Value
                };
                PagedResultOutput <ProductPriceListDto> prices = await priceAppService.GetPrices(getProductPricesInput);

                CreateOrUpdateProductModalViewModel nullable = createOrUpdateProductModalViewModel;
                IReadOnlyList <ProductPriceListDto> items    = prices.Items;
                nullable.CanMakeActive = new bool?((
                                                       from x in items
                                                       where x.IsActive
                                                       select x).Any <ProductPriceListDto>());
            }
            List <SelectListItem> selectListItems = new List <SelectListItem>();

            foreach (Lookup lookupItem in (new LookupFill("QuantityTypes", -1)).LookupItems)
            {
                SelectListItem selectListItem = new SelectListItem()
                {
                    Text     = lookupItem.Text,
                    Value    = lookupItem.Value,
                    Disabled = lookupItem.Disabled,
                    Selected = lookupItem.Selected
                };
                selectListItems.Add(selectListItem);
            }
            SelectListItem selectListItem1 = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems.Insert(0, selectListItem1);
            this.ViewData["QuantitySoldInTypes"] = selectListItems;
            return(this.PartialView("_CreateOrUpdateModal", createOrUpdateProductModalViewModel));
        }