protected void CreateUser_Click(object sender, EventArgs e) { if (IsValid) { try { TravelAgencyService service = new TravelAgencyService(); try { if (FirmPanel.Visible) { CreateUser(FirmData.EmailString, FirmData.PasswordString, service, () => { service.CreateFirm(FirmData.Firm, FirmData.GetAddressEntity(service), FirmData.EmailString); }); } else if (PersonPanel.Visible) { CreateUser(PersonData.EmailString, PersonData.PasswordString, service, () => { service.CreatePerson(PersonData.Person, PersonData.GetAddressEntity(service), PersonData.EmailString); }); } } finally { service.Dispose(); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); } } }