Пример #1
0
        public async Task <ActionResult> EditSupplierModal(int supplierId)
        {
            var output = await _supplierService.GetSupplierForEdit(new EntityDto(supplierId));

            var model = ObjectMapper.Map <EditSupplierModalViewModel>(output);

            return(View("_EditSupplierModal", model));
        }
Пример #2
0
        public async Task <PartialViewResult> CreateOrEditModal(int?id)
        {
            ISupplierAppService    supplierAppService = this._supplierAppService;
            NullableIdInput <long> nullableIdInput    = new NullableIdInput <long>()
            {
                Id = id
            };
            CreateOrEditSupplierModalViewModel createOrEditSupplierModalViewModel = new CreateOrEditSupplierModalViewModel(await supplierAppService.GetSupplierForEdit(nullableIdInput));
            List <SelectListItem> selectListItems = new List <SelectListItem>();

            using (HttpClient httpClient = new HttpClient())
            {
                string str = this.Url.RouteUrl("DefaultApiWithAction", new { httproute = "", controller = "Generic", action = "GetCountriesAsSelectListItems", countryId = 0, selectedCountryId = createOrEditSupplierModalViewModel.Supplier.CountryId }, this.Request.Url.Scheme);
                using (HttpResponseMessage async = await httpClient.GetAsync(str))
                {
                    if (async.IsSuccessStatusCode)
                    {
                        string str1 = await async.Content.ReadAsStringAsync();

                        selectListItems = JsonConvert.DeserializeObject <List <SelectListItem> >(str1);
                    }
                }
            }
            List <SelectListItem> selectListItems1 = selectListItems;
            SelectListItem        selectListItem   = new SelectListItem()
            {
                Text     = "",
                Value    = "",
                Disabled = false
            };

            selectListItems1.Insert(0, selectListItem);
            this.ViewData["Countries"] = selectListItems.AsEnumerable <SelectListItem>();
            return(this.PartialView("_CreateOrEditModal", createOrEditSupplierModalViewModel));
        }