public void UpdateFleetOwner(FleetOwnerEntity foe) { var dbFleetOwner = DataContext.FleetOwners.Single(d => d.FleetOwnerId == foe.FleetOwnerId); if (foe.CompanyId == -1) { dbFleetOwner.Company = null; } else { dbFleetOwner.CompanyId = foe.CompanyId; } dbFleetOwner.OwnerName = foe.FleetOwnerName; DataContext.SubmitChanges(); }
private void UpdateFleetPopup(FleetOwnerEntity foe) { lblFleetCountry.Text = foe.CountryName; lblFleetCode.Text = foe.FleetOwnerCode; tbFleetName.Text = foe.FleetOwnerName; hfSelectedFleetId.Value = foe.FleetOwnerId.ToString(CultureInfo.InvariantCulture); PopulateCompanyDropdown(foe.CountryId, 0, ddlCompany); if (foe.CompanyId.HasValue) { ddlCompany.SelectedValue = foe.CompanyId.ToString(); } else { ddlCompany.SelectedIndex = 0; } }
protected void btnSaveFleet_Click(object sender, EventArgs e) { var fleetOwnerId = int.Parse(hfSelectedFleetId.Value); var companyId = ddlCompany.SelectedValue == string.Empty ? (int?)null : int.Parse(ddlCompany.SelectedValue); var entityToUpdate = new FleetOwnerEntity { FleetOwnerId = fleetOwnerId, CompanyId = companyId, FleetOwnerName = tbFleetName.Text, }; using (var dataAccess = new FleetOwnerDataAccess()) { dataAccess.UpdateFleetOwner(entityToUpdate); LoadFleetData(dataAccess); } }