public async Task <ActionResult> _AddEditBranch(int IdData = -1) { trxBranchOfficeForm myDataForm = new trxBranchOfficeForm(); if (IdData > 0) { HttpResponseMessage responseMessage = await client.GetAsync(url + "/" + IdData); if (responseMessage.IsSuccessStatusCode) { var responseData = responseMessage.Content.ReadAsStringAsync().Result; var myData = JsonConvert.DeserializeObject <trxBranchOffice>(responseData); myDataForm.InjectFrom(myData); myDataForm = PopulatePhoneFax(myDataForm); return(View(myDataForm)); } return(View("Error")); } else { return(View(myDataForm)); } }
private trxBranchOfficeForm PopulatePhoneFax(trxBranchOfficeForm myDataForm) { trxBranchOfficeForm myDataReturn = new trxBranchOfficeForm(); myDataReturn.InjectFrom(myDataForm); if (!string.IsNullOrEmpty(myDataReturn.Telephone1) && myDataReturn.Telephone1.Contains("-")) { var arrReturn = myDataReturn.Telephone1.Split('-'); if (arrReturn.Length == 2) { myDataReturn.Phone1_1 = arrReturn[0]; myDataReturn.Phone1_2 = arrReturn[1]; } else if (arrReturn.Length == 1) { myDataReturn.Phone1_1 = arrReturn[0]; } } if (!string.IsNullOrEmpty(myDataReturn.Telephone2) && myDataReturn.Telephone2.Contains("-")) { var arrReturn = myDataReturn.Telephone2.Split('-'); if (arrReturn.Length == 2) { myDataReturn.Phone2_1 = arrReturn[0]; myDataReturn.Phone2_2 = arrReturn[1]; } else if (arrReturn.Length == 1) { myDataReturn.Phone2_1 = arrReturn[0]; } } if (!string.IsNullOrEmpty(myDataReturn.Telephone3) && myDataReturn.Telephone3.Contains("-")) { var arrReturn = myDataReturn.Telephone3.Split('-'); if (arrReturn.Length == 2) { myDataReturn.Phone3_1 = arrReturn[0]; myDataReturn.Phone3_2 = arrReturn[1]; } else if (arrReturn.Length == 1) { myDataReturn.Phone3_1 = arrReturn[0]; } } if (!string.IsNullOrEmpty(myDataReturn.Fax1) && myDataReturn.Fax1.Contains("-")) { var arrReturn = myDataReturn.Fax1.Split('-'); if (arrReturn.Length == 2) { myDataReturn.Fax1_1 = arrReturn[0]; myDataReturn.Fax1_2 = arrReturn[1]; } else if (arrReturn.Length == 1) { myDataReturn.Fax1_1 = arrReturn[0]; } } if (!string.IsNullOrEmpty(myDataReturn.Fax2) && myDataReturn.Fax2.Contains("-")) { var arrReturn = myDataReturn.Fax2.Split('-'); if (arrReturn.Length == 2) { myDataReturn.Fax2_1 = arrReturn[0]; myDataReturn.Fax2_2 = arrReturn[1]; } else if (arrReturn.Length == 1) { myDataReturn.Fax2_1 = arrReturn[0]; } } return(myDataReturn); }