Esempio n. 1
0
		public void FillPhones(ICollection<Phone> phones, PhonesViewModel phonesViewModel)
		{
			if (phonesViewModel != null)
			{
				var phonesArray = phones.ToArray();
				foreach (var phone in phonesArray)
				{
					if (!phonesViewModel.PhoneItems.Any(pi => pi.Id == phone.Id.ToString()))
					{
						phones.Remove(phone);
					}
				}
				foreach (var phoneItem in phonesViewModel.PhoneItems)
				{
					int phoneItemId;
					if (Int32.TryParse(phoneItem.Id, out phoneItemId))
					{
						var phone = phones.Single(p => p.Id == phoneItemId);
						if (!String.IsNullOrWhiteSpace(phoneItem.Number))
						{
							phone.Number = phoneItem.Number;
							phone.Type = phoneItem.PhoneType;
						}
						else
						{
							phones.Remove(phone);
						}
					}
					else
					{
						if (!String.IsNullOrWhiteSpace(phoneItem.Number))
						{
							var phone = new Phone();
							phone.Number = phoneItem.Number;
							phone.Type = phoneItem.PhoneType;
							phones.Add(phone);
						}
					}
				}
			}
		}
Esempio n. 2
0
		public PhonesViewModel GetPhonesViewModel(ICollection<Phone> phones)
		{
			var phonesViewModel = new PhonesViewModel();
			phonesViewModel.PhoneItems = new List<PhoneItemViewModel>();

			if (phones != null)
			{
				foreach (var phone in phones)
				{
					var phoneItemViewModel = new PhoneItemViewModel();
					phoneItemViewModel.Id = phone.Id.ToString();
					phoneItemViewModel.Number = phone.Number;
					phoneItemViewModel.PhoneType = phone.Type;
					phonesViewModel.PhoneItems.Add(phoneItemViewModel);
				}
			}

			if (phonesViewModel.PhoneItems.Count == 0)
			{
				phonesViewModel.PhoneItems.Add(new PhoneItemViewModel() { Id = Guid.NewGuid().ToString(), PhoneType = PhoneType.Mobile });
			}

			return phonesViewModel;
		}
Esempio n. 3
0
		public PartialViewResult AddPhone()
		{
			var phonesViewModel = new PhonesViewModel();
			phonesViewModel.PhoneItems = new List<PhoneItemViewModel> { new PhoneItemViewModel { Id = Guid.NewGuid().ToString(), PhoneType = PhoneType.Mobile } };
			var appraiserContactViewModel = new AppraiserUserContactViewModel { Phones = phonesViewModel };
			return PartialView("AppraiserTabs/Contact", appraiserContactViewModel);
		}
		public PartialViewResult AddEmptyPhone()
		{
			var phone = new PhoneItemViewModel { Id = Guid.NewGuid().ToString(), PhoneType = PhoneType.Mobile };
			var phonesViewModel = new PhonesViewModel { PhoneItems = new List<PhoneItemViewModel> { phone } };
			var model = new AppraisalCompanyContactViewModel { Phones = phonesViewModel };

			ViewBag.ExecuteBeginForm = true;
			ViewBag.ControllerName = CurrentControllerName;
			return PartialView("Tables/AppraisalCompanyPhones", model);
		}
Esempio n. 5
0
		public PartialViewResult AddEmptyPhone()
		{
			var phone = new PhoneItemViewModel { Id = Guid.NewGuid().ToString(), PhoneType = PhoneType.Mobile };
			var phonesViewModel = new PhonesViewModel { PhoneItems = new List<PhoneItemViewModel> { phone } };
			var model = new AppraiserUserCreateViewModel();
			model.Contact.Phones = phonesViewModel;
			ViewBag.ExecuteBeginForm = true;
			ViewBag.AreaName = DVS.Logic.Constants.Areas.UserManagement;
			ViewBag.ControllerName = NameHelper.AppraiserUserAdd.Controller;
			return PartialView(Constants.Views.AppraiserPhonesPartial, model);
		}