public ViewModel() { AccessLevel = 0; var request = HttpContext.Current.Request; if (request != null) { if (request["personContactText"] != null) { var phone = request["personContactText"]; Model.Contact.PhoneNumber = request["personContactText"]; Model.Contact.ContactText = request["personContactText"]; Model.Contact.OtherContact = request["personContactText"]; Kesco.Territories.BusinessLogic.AreaPhoneInfo area = new Territories.BusinessLogic.AreaPhoneInfo(); AdjustPhoneNumber(ref area, ref phone); Model.Direction = area.Направление; Model.Contact.CountryPhoneCode = area.ТелКодСтраны; Model.Contact.CityPhoneCode = area.ТелКодВСтране; Model.Contact.PhoneNumber = phone; } } InitContactTypes(); }
public ActionResult AdjustPhone(string control, DataModel model) { string phoneCode = null; control = control ?? String.Empty; if (model.AreaID.HasValue) { phoneCode = Territories.BusinessLogic.Repository.Territories.GetPhoneCode( model.AreaID.Value, String.IsNullOrEmpty(model.Contact.CountryPhoneCode) ) ?? String.Empty; if (control.EndsWith("CountryPhoneCode")) { model.Contact.CountryPhoneCode = phoneCode; } if (control.EndsWith("CityPhoneCode")) { model.Contact.CityPhoneCode = phoneCode; } } Kesco.Territories.BusinessLogic.AreaPhoneInfo area = new Territories.BusinessLogic.AreaPhoneInfo() { Направление = String.Empty, ТелКодВСтране = model.Contact.CityPhoneCode ?? String.Empty, ТелКодСтраны = model.Contact.CountryPhoneCode ?? String.Empty }; string phone = model.Contact.PhoneNumber ?? String.Empty; ViewModel.AdjustPhoneNumber(ref area, ref phone); string script = String.Format(@" //(function() {{ var phoneInfo = {0}; ViewModel.Model.Contact.CountryPhoneCode(phoneInfo.CountryPhoneCode); ViewModel.Model.Contact.CityPhoneCode(phoneInfo.CityPhoneCode); ViewModel.Model.Contact.PhoneNumber(phoneInfo.PhoneNumber); ViewModel.Model.Direction(phoneInfo.Direction); updateContactText(); //}})();" , Kesco.Web.Mvc.Json.Serialize(new { CountryPhoneCode = area.ТелКодСтраны, CityPhoneCode = area.ТелКодВСтране, Direction = area.Направление, PhoneNumber = phone }, true) ); return(JavaScript(script)); }
public void InitFromContact(int contactId) { var contact = Repository.Contacts.GetInstance(contactId); if (contact == null) { throw new ApplicationException(String.Format(Resources.Resources.Persons_Contact_NotFound, contactId)); } Model.Contact.ID = contact.ID; Model.Contact.PersonLinkID = contact.PersonLinkID; Model.Contact.ContactTypeID = contact.ContactTypeID; Model.Contact.ContactText = contact.ContactText; Model.Contact.ContactTextRL = contact.ContactTextRL; Model.Contact.CountryID = contact.CountryID; Model.Contact.Zip = contact.Zip; Model.Contact.Region = contact.Region; Model.Contact.CityName = contact.CityName; Model.Contact.CityNameRus = contact.CityNameRus; Model.Contact.Address = contact.Address; Model.Contact.CountryPhoneCode = contact.CountryPhoneCode; Model.Contact.CityPhoneCode = contact.CityPhoneCode; Model.Contact.PhoneNumber = contact.PhoneNumber; Model.Contact.PhoneNumberAdd = contact.PhoneNumberAdd; Model.Contact.PhoneNumberCorporative = contact.PhoneNumberCorporative; Model.Contact.OtherContact = contact.OtherContact; Model.Contact.Comment = contact.Comment; Model.Contact.ChangedBy = contact.ChangedBy; Model.Contact.ChangedDate = contact.ChangedDate; Kesco.Territories.BusinessLogic.AreaPhoneInfo area = new Territories.BusinessLogic.AreaPhoneInfo() { Направление = String.Empty, ТелКодВСтране = contact.CityPhoneCode ?? String.Empty, ТелКодСтраны = contact.CountryPhoneCode ?? String.Empty }; string phone = contact.PhoneNumber ?? String.Empty; AdjustPhoneNumber(ref area, ref phone); Model.Direction = area.Направление; if (contact.PersonID.HasValue) { InitFromPerson(contact.PersonID.Value); } if (contact.PersonLinkID.HasValue) { InitFromPersonLink(contact.PersonLinkID.Value); } }