public async Task <GetAddressForEditOutput> GetAddressForEdit(EntityDto input) { var address = await _addressRepository.FirstOrDefaultAsync(input.Id); var output = new GetAddressForEditOutput { Address = ObjectMapper.Map <CreateOrEditAddressDto>(address) }; // TODO: REMOVE THESE - NOT NEEDED, and exposes info accross tenants!!! if (output.Address.CustomerId != null) { var _lookupCustomer = await _lookup_customerRepository.FirstOrDefaultAsync((int)output.Address.CustomerId); output.CustomerName = _lookupCustomer.Name.ToString(); } if (output.Address.AssetOwnerId != null) { var _lookupAssetOwner = await _lookup_assetOwnerRepository.FirstOrDefaultAsync((int)output.Address.AssetOwnerId); output.AssetOwnerName = _lookupAssetOwner.Name.ToString(); } if (output.Address.VendorId != null) { var _lookupVendor = await _lookup_vendorRepository.FirstOrDefaultAsync((int)output.Address.VendorId); output.VendorName = _lookupVendor.Name.ToString(); } return(output); }
public CreateOrUpdateAddressModalViewModel(GetAddressForEditOutput output) { output.MapTo <GetAddressForEditOutput, CreateOrUpdateAddressModalViewModel>(this); }
public async Task <PartialViewResult> CreateOrUpdateAddressModal(long?ownerId, string ownerType, int tenantId, long?id = null) { long? impersonatorUserId; string str; long value; long num; IGenericAppService genericAppService = this._genericAppService; NullableIdInput <long> nullableIdInput = new NullableIdInput <long>() { Id = id }; GetAddressForEditOutput addressForEdit = await genericAppService.GetAddressForEdit(nullableIdInput); if (string.IsNullOrEmpty(addressForEdit.Address.OwnerType)) { addressForEdit.Address.OwnerType = ownerType; AddressEditDto address = addressForEdit.Address; num = (ownerId.HasValue ? ownerId.Value : (long)0); address.OwnerId = num; } CreateOrUpdateAddressModalViewModel createOrUpdateAddressModalViewModel = new CreateOrUpdateAddressModalViewModel(addressForEdit); List <SelectListItem> selectListItems = new List <SelectListItem>(); str = (ownerType == "FillLot" ? "FillLotAddressTypes" : "AddressTypes"); foreach (Lookup lookupItem in (new LookupFill(str, tenantId)).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["AddressTypes"] = selectListItems; List <SelectListItem> selectListItems1 = new List <SelectListItem>(); using (HttpClient httpClient = new HttpClient()) { string str1 = this.Url.RouteUrl("DefaultApiWithAction", new { httproute = "", controller = "Generic", action = "GetCountriesAsSelectListItems", countryId = 0, selectedCountryId = createOrUpdateAddressModalViewModel.Address.CountryId }, this.Request.Url.Scheme); using (HttpResponseMessage async = await httpClient.GetAsync(str1)) { if (async.IsSuccessStatusCode) { string str2 = await async.Content.ReadAsStringAsync(); selectListItems1 = JsonConvert.DeserializeObject <List <SelectListItem> >(str2); } } } List <SelectListItem> selectListItems2 = selectListItems1; SelectListItem selectListItem2 = new SelectListItem() { Text = "", Value = "", Disabled = false }; selectListItems2.Insert(0, selectListItem2); this.ViewData["Countries"] = selectListItems1.AsEnumerable <SelectListItem>(); string str3 = this.L("KeyName_CustomersRole"); IRepository <Role> repository = this._roleRepository; List <Role> allListAsync = await repository.GetAllListAsync((Role m) => m.TenantId == (int?)((this.AbpSession.ImpersonatorTenantId.HasValue ? this.AbpSession.ImpersonatorTenantId.Value : this.AbpSession.TenantId.Value)) && m.DisplayName == str3); List <Role> roles = allListAsync; bool count = roles.Count == 1; if (count) { UserManager userManager = this._userManager; if (this.AbpSession.ImpersonatorUserId.HasValue) { impersonatorUserId = this.AbpSession.ImpersonatorUserId; value = impersonatorUserId.Value; } else { impersonatorUserId = this.AbpSession.UserId; value = impersonatorUserId.Value; } bool flag = await userManager.IsInRoleAsync(value, roles[0].Name); count = flag; } if (count) { ((dynamic)this.ViewBag).IsCustomer = true; } return(this.PartialView("_CreateOrUpdateAddressModal", createOrUpdateAddressModalViewModel)); }