public static AddressViewModel GetAddressViewModel(Address address) { if (address == null) return null; return new AddressViewModel { CEP = address.CEP, City = address.City, Complement = address.Complement, Neighborhood = address.Neighborhood, StateProvince = address.StateProvince, Street = address.Street, }; }
/// <summary> /// Create a new Address object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="practiceId">Initial value of the PracticeId property.</param> public static Address CreateAddress(global::System.Int32 id, global::System.Int32 practiceId) { Address address = new Address(); address.Id = id; address.PracticeId = practiceId; return address; }
/// <summary> /// Deprecated Method for adding a new object to the Addresses EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAddresses(Address address) { base.AddObject("Addresses", address); }
public ActionResult Edit(PracticeHomeControllerViewModel formModel) { if (this.ModelState.IsValid) { formModel.PracticeName = Regex.Replace(formModel.PracticeName.Trim(), @"\s+", " "); this.DbPractice.Name = formModel.PracticeName; this.DbPractice.WindowsTimeZoneId = TimeZoneDataAttribute.GetAttributeFromEnumValue( (TypeTimeZone)formModel.PracticeTimeZone).Id; this.DbPractice.PhoneMain = formModel.PhoneMain; this.DbPractice.PhoneAlt = formModel.PhoneAlt; this.DbPractice.SiteUrl = formModel.SiteUrl; this.DbPractice.Email = formModel.Email; var address = this.DbPractice.Address; if (address == null) this.DbPractice.Address = address = new Address(); address.PracticeId = this.DbPractice.Id; address.CEP = formModel.Address.CEP; address.City = formModel.Address.City; address.Complement = formModel.Address.Complement; address.Neighborhood = formModel.Address.Neighborhood; address.StateProvince = formModel.Address.StateProvince; address.Street = formModel.Address.Street; this.db.SaveChanges(); return this.RedirectToAction("Index"); } return this.View(formModel); }