public ActionResult Addresses() { try { Models.CUser User = new Models.CUser(); Models.CAddress DefaultAddress = new Models.CAddress(); List <Models.CAddress> AddressList = new List <Models.CAddress>(); User = User.GetCurrentUser(); DefaultAddress = Models.CAddress.GetDefaultAddress(User.UserID); User.intStateID = DefaultAddress.intStateID; User.strCity = DefaultAddress.strCity; User.strAddress = DefaultAddress.strAddress; User.strZipCode = DefaultAddress.strZipCode; AddressList = Models.CAddress.GetAddressList(User.UserID); if (AddressList.Count > 1) { User.AddressList = AddressList; } return(View(User)); } catch (Exception ex) { throw new Exception(ex.Message); } }
public ActionResult Addresses(FormCollection Collection) { try { Models.CUser User = new Models.CUser(); Models.CDatabase db = new Models.CDatabase(); Models.CAddress EnteredAddress = new Models.CAddress(); Models.COrder order = new Models.COrder(); Models.CUser user = new Models.CUser(); int intAddressID; EnteredAddress.strAddress = Collection["strAddress"]; EnteredAddress.strCity = Collection["strCity"]; EnteredAddress.intStateID = Convert.ToInt32(Collection["intStateID"]); EnteredAddress.strZipCode = Collection["strZipCode"]; intAddressID = EnteredAddress.DoesAddressExist(EnteredAddress); user = user.GetCurrentUser(); order = Models.COrder.GetOrder(0, user.UserID, 1); if (intAddressID > 0) { order.intShippingAddressID = intAddressID; db.UpdateOrder(order); } else { intAddressID = db.InsertAddress(EnteredAddress); order.intShippingAddressID = intAddressID; db.UpdateOrder(order); } return(RedirectToAction("Payment")); } catch (Exception ex) { throw new Exception(ex.Message); } }