public void AddAddress(AddAddressBM bind, string userName) { Customer customer = Context.Customers.FirstOrDefault(cust => cust.User.UserName == userName); Address address = Mapper.Map <AddAddressBM, Address>(bind); customer.Addresses.Add(address); Context.SaveChanges(); }
public ActionResult AddAddress([Bind(Include = "City, Streat, PhoneNumber, PostCode")] AddAddressBM bind) { if (this.ModelState.IsValid) { string userName = User.Identity.Name; service.AddAddress(bind, userName); return(this.RedirectToAction("Profile")); } return(View()); }