示例#1
0
        public ActionResult EditAddress(ReceveAddress address)
        {
            if (ModelState.IsValid)
            {
                _database.Entry(address).State = EntityState.Modified;
                _database.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(address));
        }
示例#2
0
        public ActionResult EditAddress(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ReceveAddress address = _database.ReceveAddresses.Find(id);

            if (address == null)
            {
                return(HttpNotFound());
            }
            return(View(address));
        }
示例#3
0
        public ActionResult NewAddress([Bind(Include = "Consignee, Address, PhoneNumber, PostCode")] ReceveAddress receiveAddress)
        {
            if (ModelState.IsValid)
            {
                var user = Session["user"] as UserAccount;

                var dbUser = _database.Account.Find(user.UserId);

                receiveAddress.Account = dbUser;
                _database.ReceveAddresses.Add(receiveAddress);
                _database.SaveChanges();
                return(RedirectToAction("Address"));
            }

            return(View(receiveAddress));
        }