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 <CustomerDepartmentEditModel> BuildCustomerDepartmentModels(List <CustomerDepartment> customerDepartments) { var list = new List <CustomerDepartmentEditModel>(); foreach (var item in customerDepartments) { var model = new CustomerDepartmentEditModel(); model.CustomerDepartmentID = item.CustomerDepartmentID; model.CustomerDepartmentName = item.CustomerDepartmentName; model.CustomerID = item.CustomerID; model.EmailAddress = item.EmailAddress; model.Commission = item.Commission.HasValue ? item.Commission.Value : 0; model.Handling = item.Handling.HasValue ? item.Handling.Value : 0; model.RebateType = item.RebateType; model.RebateRate = item.RebateRate.HasValue ? item.RebateRate.Value : 0; model.RebateCustomerDepartmentID = item.RebateCustomerDepartmentID; //.HasValue ? item.RebateCustomerDepartmentID.Value : Guid.Empty model.RebateCustomerCompany_DepartmentName = item.RebateCustomerDepartmentID.HasValue ? _customerDepartmentService.CustomerDepartmentByCustomerDepartmentId(item.RebateCustomerDepartmentID.Value).CustomerDepartmentName : string.Empty; model.SalesPersonUserID = item.SalesPersonUserID; //model.SalesPersonName = __get_name__(item.SalesPersonUserID); //////////////////// model.InvoiceCustomerLocationID = item.InvoiceCustomerLocationID; model.InvoiceCustomerLocation_Name = _customerDepartmentLocationService .GetCustomerDepartmentLocationByLocId(item.InvoiceCustomerLocationID) .CustomerLocation.CustomerLocationName; model.InvoiceFrequency = item.InvoiceFrequency.ToString(); model.TransactionTaxReference = item.TransactionTaxReference; model.CreditTerms = item.CreditTerms.HasValue ? item.CreditTerms.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 customerDepartmentLocations = _customerDepartmentLocationService.GetCustomerDepartmentLocationListByDepId(item.CustomerDepartmentID); model.SelectedLocationIds = new List <string>(); model.LbxLocationOptions = new List <LbxViewModel>(); foreach (var cdl in customerDepartmentLocations) { model.SelectedLocationIds.Add(cdl.CustomerLocationID.ToString()); var lxbItem = new LbxViewModel(); lxbItem.Id = cdl.CustomerLocationID.ToString(); lxbItem.label = _customerLocationService.CustomerLocationById(cdl.CustomerLocationID.Value).CustomerLocationName; lxbItem.value = cdl.CustomerLocationID.ToString(); model.LbxLocationOptions.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); }