public ActionResult EidtAddressPerson(PerAddress PerAdd) { //判断用户是否登录如果没有跳转登录,登录成功后跳转回来 if (Session["LoginUserSessionModel"] == null) { return(RedirectToAction("login", "Account", new { returnUrl = Url.Action("EidtAddressPerson", "AddressPerson") })); } var person = (Session["LoginUserSessionModel"] as LoginUserSessionModel).Person; //修改 if (PerAdd.Address != null) { var personadd = _context.PerAddress.SingleOrDefault(x => x.ID == PerAdd.ID); personadd.AddressPerson = PerAdd.AddressPerson; personadd.Address = PerAdd.Address; personadd.MobiNumber = PerAdd.MobiNumber; //_context.Order.Add(orders); _context.SaveChanges(); return(Content("<script>alert('恭喜修改收货人成功!');location.href='" + Url.Action("index", "AddressPerson") + "'</script>")); } else { return(View()); } }
public ActionResult AddressPerson(PerAddress PerAdd) { //1.确认用户是否登录 是否登录过期 if (Session["LoginUserSessionModel"] == null) { return(RedirectToAction("login", "Account", new { returnUrl = Url.Action("AddressPerson", "Order") })); } var person = (Session["LoginUserSessionModel"] as LoginUserSessionModel).Person; if (PerAdd.Address != null) { var peradd = new PerAddress() { Address = PerAdd.Address, AddressPerson = PerAdd.AddressPerson, MobiNumber = PerAdd.MobiNumber }; var personadd = _context.Persons.SingleOrDefault(x => x.ID == person.ID); personadd.PerAddress.Add(peradd); //_context.Order.Add(orders); _context.SaveChanges(); return(Content("<script>alert('恭喜添加收货人成功!');location.href='" + Url.Action("index", "AddressPerson") + "'</script>")); } else { return(View()); } }