public void Edit(int id, Address address) { Address entityToEdit = (from cust in _dataContext.Addresses where cust.Id == id select cust).FirstOrDefault(); entityToEdit.IsPrimary = address.IsPrimary; entityToEdit.Addr = address.Addr; entityToEdit.City = address.City; entityToEdit.State = address.State; entityToEdit.Zip = address.Zip; entityToEdit.ModifiedDate = DateTime.Now; _dataContext.SaveChanges(); }
public void Add(int customerId, Address address) { var addr = new Address { CustomerId = customerId, Addr = address.Addr, City = address.City, State = address.State, Zip = address.Zip, IsPrimary = address.IsPrimary, ModifiedDate = DateTime.Now }; _dataContext.Addresses.AddObject(addr); _dataContext.SaveChanges(); }
public ActionResult Create(int customerId, Address address) { try { _repository.Add(customerId, address); var addressToDisplay = new AddressViewModel { Id = address.Id, CustomerId = address.CustomerId, Addr = address.Addr, City = address.City, State = address.State, Zip = address.Zip, IsPrimary = address.IsPrimary, ModifiedDate = address.ModifiedDate }; return RedirectToAction("Index", addressToDisplay); } catch { return View(); } }
public void Edit(int id, Address address) { _addressRepository.Edit(id, address); }
public void Add(int customerId, Address address) { _addressRepository.Add(customerId, address); }
public ActionResult Delete(int id, Address address) { try { Address toDelete = _repository.Get(id); _repository.Delete(id); var toDisplay = new AddressViewModel { Id = address.Id, CustomerId = toDelete.CustomerId, Addr = toDelete.Addr, City = toDelete.City, State = toDelete.State, Zip = toDelete.Zip, IsPrimary = toDelete.IsPrimary, ModifiedDate = toDelete.ModifiedDate }; return RedirectToAction("Index", toDisplay); } catch { return View(); } }
/// <summary> /// Create a new Address object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="addr">Initial value of the Addr property.</param> /// <param name="customerId">Initial value of the CustomerId property.</param> /// <param name="city">Initial value of the City property.</param> /// <param name="state">Initial value of the State property.</param> /// <param name="zip">Initial value of the Zip property.</param> /// <param name="modifiedDate">Initial value of the ModifiedDate property.</param> /// <param name="isPrimary">Initial value of the IsPrimary property.</param> public static Address CreateAddress(global::System.Int32 id, global::System.String addr, global::System.Int32 customerId, global::System.String city, global::System.String state, global::System.String zip, global::System.DateTime modifiedDate, global::System.Boolean isPrimary) { Address address = new Address(); address.Id = id; address.Addr = addr; address.CustomerId = customerId; address.City = city; address.State = state; address.Zip = zip; address.ModifiedDate = modifiedDate; address.IsPrimary = isPrimary; 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); }