public ActionResult SaveAddress(AddressModel addressModel)
        {
            //error handling
            Boolean error = addressModel == null ||
                addressModel.firstname == null ||
                addressModel.lastname == null ||
                addressModel.street_address == null ||
                addressModel.city == null ||
                addressModel.zip == null;

            if (error)
            {
                throw new Exception();
            }

            Address newAddress = new Address();
            newAddress.firstName = addressModel.firstname;
            newAddress.lastName = addressModel.lastname;
            newAddress.street_address = addressModel.street_address;
            newAddress.complex_number = addressModel.complex_number;
            newAddress.city = addressModel.city;
            newAddress.zip = addressModel.zip;
            newAddress.dateModified = DateTime.Now;

            newAddress.user_id = WebSecurity.CurrentUserId;
            newAddress.Address_State = db.Address_State.Where(st => st.state_id == addressModel.state).FirstOrDefault();
            newAddress.is_billing = addressModel.is_billing;
            newAddress.is_default = addressModel.is_default;
            if (addressModel.is_default)
            {
                Address oldDefaultAddress = db.Addresses.FirstOrDefault(ad => ad.is_default == true &&
                    ad.user_id == WebSecurity.CurrentUserId && ad.is_billing == addressModel.is_billing &&
                    ad.is_deleted == false);
                if (oldDefaultAddress != null)
                    oldDefaultAddress.is_default = false;
            }
            if (addressModel.edited_from != 0)
            {
                Address oldAddress = db.Addresses.FirstOrDefault(ad => ad.user_id == WebSecurity.CurrentUserId &&
                    ad.address_id == addressModel.edited_from);
                if (oldAddress != null)
                {
                    oldAddress.is_deleted = true;
                    newAddress.edited_from = oldAddress.address_id;
                }
            }
            newAddress.is_deleted = false;
            db.Addresses.Add(newAddress);
            db.SaveChanges();
            ShoppingCartView_Model model = new ShoppingCartView_Model();
            model.defaultAddress = newAddress;
            if (!addressModel.is_billing)
                return PartialView("AddressPage", model);
            else
                return PartialView("PaymentOptions", model);
        }
 public ActionResult AddressPage()
 {
     ShoppingCartView_Model model = new ShoppingCartView_Model();
     return PartialView(model);
 }
 public ActionResult PaymentOptions()
 {
     ShoppingCartView_Model model = new ShoppingCartView_Model();
     return PartialView(model);
 }