public List <SupplierContactEditModel> BuildSupplierContactModels(List <SupplierContact> supplierContacts) { var list = new List <SupplierContactEditModel>(); foreach (var item in supplierContacts) { var model = new SupplierContactEditModel(); model.SupplierContactID = item.SupplierContactID; model.SupplierID = item.SupplierID; model.SortOrder = item.SortOrder.HasValue ? item.SortOrder.Value : Guid.Empty; model.ContactID = item.ContactID; var contact = _contactService.GetContactById(item.ContactID); model.EmailAddress = contact.EmailAddress; model.FirstName = contact.FirstName; model.LastName = contact.LastName; model.Title = contact.Title; model.ContactType = contact.ContactType; model.ContactReference = contact.ContactReference; model.DDITelephoneNo = contact.DDITelephoneNo; model.MobileNo = contact.MobileNo; model.NoteID = contact.NoteID; model.Notes = contact.NoteID.HasValue ? _noteService.Find(contact.NoteID.Value).NoteText : string.Empty; // setup LxbViewModel of ListBox var supplierContactLocations = _supplierContactLocationService.GetSupplierContactLocationListByConId(item.SupplierContactID); model.SelectedLocationIds = new List <string>(); model.LbxLocationOptions = new List <LbxViewModel>(); foreach (var scl in supplierContactLocations) { model.SelectedLocationIds.Add(scl.SupplierLocationID.ToString()); var lxbItem = new LbxViewModel(); lxbItem.Id = scl.SupplierLocationID.ToString(); lxbItem.label = _supplierLocationService.GetSupplierLocationById(scl.SupplierLocationID).SupplierLocationName; lxbItem.value = scl.SupplierLocationID.ToString(); model.LbxLocationOptions.Add(lxbItem); } var supplierContactDepartments = _supplierContactDepartmentService.GetSupplierContactDepartmentListByConId(item.SupplierContactID); model.SelectedDepartmentIds = new List <string>(); model.LbxDepartmentOptions = new List <LbxViewModel>(); foreach (var scd in supplierContactDepartments) { model.SelectedDepartmentIds.Add(scd.SupplierDepartmentID.ToString()); var lxbItem = new LbxViewModel(); lxbItem.Id = scd.SupplierDepartmentID.ToString(); lxbItem.label = _supplierDepartmentService.SupplierDepartmentById(scd.SupplierDepartmentID).SupplierDepartmentName; lxbItem.value = scd.SupplierDepartmentID.ToString(); model.LbxDepartmentOptions.Add(lxbItem); } list.Add(model); } return(list); }
public List <SupplierDepartmentEditModel> BuildSupplierDepartmentModels(List <SupplierDepartment> supplierDepartments) { var list = new List <SupplierDepartmentEditModel>(); foreach (var item in supplierDepartments) { var model = new SupplierDepartmentEditModel(); model.SupplierDepartmentID = item.SupplierDepartmentID; model.SupplierDepartmentName = item.SupplierDepartmentName; model.SupplierID = item.SupplierID; model.EmailAddress = item.EmailAddress; model.Commission = item.Commission.HasValue ? item.Commission.Value : 0; model.Handling = item.Handling.HasValue ? item.Handling.Value : 0; model.GivesRebate = item.GivesRebate; model.RebateAmount = item.Rebate.HasValue ? item.Rebate.Value : 0; model.CountryID = item.CountryID.HasValue ? item.CountryID.Value : Guid.Empty; model.CountryName = item.CountryID.HasValue ? _countryService.CountryById(item.CountryID.Value).CountryName : string.Empty; model.IsTransactionTaxExempt = item.IsTransactionTaxExempt; model.TransactionTaxReference = item.TransactionTaxReference; model.CreditTerm = item.CreditTerm.HasValue ? item.CreditTerm.Value : 0; model.CreditLimit = item.CreditLimit.HasValue ? item.CreditLimit.Value : 0; model.NoteID = item.NoteID; model.Notes = item.NoteID.HasValue ? _noteService.Find(item.NoteID.Value).NoteText : string.Empty; // setup LxbViewModel of ListBox var supplierDepartmentLocations = _supplierDepartmentLocationService.GetSupplierDepartmentLocationListByDepId(item.SupplierDepartmentID); model.SelectedLocationIds = new List <string>(); model.LbxLocationOptions = new List <LbxViewModel>(); foreach (var sdl in supplierDepartmentLocations) { model.SelectedLocationIds.Add(sdl.SupplierLocationID.ToString()); var lxbItem = new LbxViewModel(); lxbItem.Id = sdl.SupplierLocationID.ToString(); lxbItem.label = _supplierLocationService.GetSupplierLocationById(sdl.SupplierLocationID).SupplierLocationName; lxbItem.value = sdl.SupplierLocationID.ToString(); model.LbxLocationOptions.Add(lxbItem); } list.Add(model); } return(list); }