protected void CreateUser(object sender, EventArgs e) { int addressId = 0; if (!string.IsNullOrEmpty(txtAddressLineOne.Text) && !string.IsNullOrEmpty(txtDistrict.Text) && !string.IsNullOrEmpty(txtPincode.Text) && !string.IsNullOrEmpty(txtVillage.Text)) { var address = PageDataService.Address(txtAddressLineOne.Text, txtVillage.Text, txtDistrict.Text, txtPincode.Text); if (address != null) { addressId = address.AddressId; } } if (!string.IsNullOrEmpty(txtUserName.Text) && !string.IsNullOrEmpty(txtUserEmail.Text) && !string.IsNullOrEmpty(txtUserPassword.Text) && addressId != 0) { var user = PageDataService.AddUser(txtUserName.Text, txtUserEmail.Text, txtUserPassword.Text, Convert.ToDateTime(wdcEffectiveDate.Value), Convert.ToDateTime(wdcExpirationDate.Value), addressId); if (user != null) { foreach (ListItem item in chklstGroup.Items) { if (item.Selected) { PageDataService.AddUserGroupAssociation(Convert.ToInt32(item.Value), user.UserId); } } } Response.Redirect(Request.RawUrl, false); } }