本文整理汇总了C#中Customer.GetFromStorage方法的典型用法代码示例。如果您正苦于以下问题:C# Customer.GetFromStorage方法的具体用法?C# Customer.GetFromStorage怎么用?C# Customer.GetFromStorage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Customer
的用法示例。
在下文中一共展示了Customer.GetFromStorage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Initialize
protected override void Initialize(System.Web.Routing.RequestContext requestContext) {
base.Initialize(requestContext);
HttpContext ctx = System.Web.HttpContext.Current;
ViewBag.year = UDF.GetYearCookie(ctx);
ViewBag.make = UDF.GetMakeCookie(ctx);
ViewBag.model = UDF.GetModelCookie(ctx);
ViewBag.style = UDF.GetStyleCookie(ctx);
ViewBag.vehicleID = UDF.GetVehicleCookie(ctx);
// Get the theme ID
int themeID = new Theme().getTheme(ctx);
ViewBag.themeID = themeID;
if (themeID > 0) {
// if there is an active theme, get the files
string cname = this.ControllerContext.Controller.ToString();
Dictionary<int, List<ThemeFile>> themefiles = new Theme().getFiles(ctx,UDF.GetControllerName(cname));
ViewBag.themefiles = themefiles;
}
// We're gonna dump our Customer Session object out
Customer customer = new Customer();
customer.GetFromStorage(ctx);
Settings settings = new Settings();
ViewBag.settings = settings;
ViewBag.customer = customer;
}
示例2: Index
public async Task<ActionResult> Index() {
HttpContext ctx = System.Web.HttpContext.Current;
var pcats = CURTAPI.GetParentCategoriesAsync();
await Task.WhenAll(new Task[] { pcats });
ViewBag.parent_cats = await pcats;
// Instantiate our Customer object
Customer cust = new Customer();
// Retrieve from Session/Cookie
cust.GetFromStorage(ctx);
if (!cust.LoggedIn(ctx)) {
return RedirectToAction("Index","Authenticate");
}
// Get the Customer record
cust.Get();
cust.BindAddresses();
ViewBag.countries = UDF.GetCountries();
ViewBag.cust = cust;
ViewBag.error = TempData["error"];
return View();
}
示例3: ResetPassword
public ActionResult ResetPassword() {
HttpContext ctx = System.Web.HttpContext.Current;
Customer cust = new Customer();
cust.GetFromStorage(ctx);
if (!cust.LoggedIn(ctx)) {
return RedirectToAction("Index", "Authenticate");
}
string message = "";
try {
string current = Request.Form["current"];
string newpw = Request.Form["new"];
string confirm = Request.Form["confirm"];
if (String.IsNullOrEmpty(current) || String.IsNullOrEmpty(newpw) || String.IsNullOrEmpty(confirm)) {
throw new Exception("You must enter all password fields. Try Again");
}
cust.ValidateCurrentPassword(current);
cust.ValidatePasswords(newpw, confirm);
cust.UpdatePassword();
message = "Your password was successfully updated.";
} catch (Exception e) {
message = e.Message;
}
return RedirectToAction("Password", new { message = message });
}
示例4: DeleteAddress
public ActionResult DeleteAddress(int id = 0)
{
Customer cust = new Customer();
cust.GetFromStorage();
Address a = new Address().Get(id);
cust.ClearAddress(a.ID);
if (a.cust_id == cust.ID) {
a.Delete(id);
}
return RedirectToAction("Addresses");
}
示例5: Login
public ActionResult Login(string email = "", string password = "", int remember = 0) {
try {
HttpContext ctx = System.Web.HttpContext.Current;
/**
* Store any Customer object from Session/Cookie into a tmp object
* We'll remove the cart from the tmp object and add it to our new Authenticated Customer
*/
Customer tmp = new Customer();
tmp.GetFromStorage(ctx);
Cart tmp_cart = tmp.Cart;
string enc_password = UDF.EncryptString(password);
EcommercePlatformDataContext db = new EcommercePlatformDataContext();
Customer cust = new Customer {
email = email,
password = enc_password
};
cust.Login();
cust.password = "Ya'll suckas got ketchup'd!";
if (tmp_cart.CartItems.Count == 0) {
try {
Cart cust_cart = tmp_cart;
cust_cart = db.Carts.Where(x => x.cust_id == cust.ID).Where(x => x.payment_id == 0).OrderByDescending(x => x.last_updated).First<Cart>();
tmp_cart.RemoveCart();
tmp.Cart = cust_cart;
} catch {
tmp_cart.UpdateCart(ctx, cust.ID);
}
} else {
tmp_cart.UpdateCart(ctx, cust.ID);
}
HttpCookie cook = new HttpCookie("hdcart", tmp.Cart.ID.ToString());
if (remember != 0) {
cook.Expires = DateTime.Now.AddDays(30);
}
Response.Cookies.Add(cook);
HttpCookie authed = new HttpCookie("authenticated", "1");
if (remember != 0) {
cook.Expires = DateTime.Now.AddDays(30);
}
Response.Cookies.Add(authed);
return RedirectToAction("Index", "Cart");
} catch (Exception e) {
TempData["error"] = e.Message;
return RedirectToAction("Index");
}
}
示例6: AddBillingAddress
//[RequireHttps]
public ActionResult AddBillingAddress()
{
try {
// Create Customer
Customer customer = new Customer();
customer.GetFromStorage();
if (!customer.LoggedIn()) {
return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
}
if (customer.Cart.payment_id == 0) {
Address billing = new Address();
// Build out our Billing object
billing = new Address {
first = Request.Form["bfirst"],
last = Request.Form["blast"],
street1 = Request.Form["bstreet1"],
street2 = Request.Form["bstreet2"],
city = Request.Form["bcity"],
postal_code = Request.Form["bzip"],
residential = (Request.Form["bresidential"] == null) ? false : true,
active = true
};
try {
billing.state = Convert.ToInt32(Request.Form["bstate"]);
} catch (Exception) {
throw new Exception("You must select a billing state/province.");
}
billing.Save(customer.ID);
if (customer.billingID == 0) {
customer.SetBillingDefaultAddress(billing.ID);
}
if (customer.shippingID == 0) {
customer.SetShippingDefaultAddress(billing.ID);
}
// Retrieve Customer from Sessions/Cookie
customer.Cart.SetBilling(billing.ID);
if (customer.Cart.ship_to == 0) {
customer.Cart.SetShipping(billing.ID);
}
} else {
UDF.ExpireCart(customer.ID);
return RedirectToAction("index");
}
} catch { }
return RedirectToAction("shipping");
}
示例7: AddAjax
public string AddAjax(int id = 0, int qty = 0)
{
// Create Customer
Customer customer = new Customer();
// Retrieve Customer from Sessions/Cookie
customer.GetFromStorage();
if (customer.Cart.payment_id == 0) {
customer.Cart.Add(id, qty);
} else {
UDF.ExpireCart(customer.ID);
}
return getCart();
}
示例8: Password
public async Task<ActionResult> Password(string message = "") {
HttpContext ctx = System.Web.HttpContext.Current;
var pcats = CURTAPI.GetParentCategoriesAsync();
await Task.WhenAll(new Task[] { pcats });
ViewBag.parent_cats = await pcats;
ViewBag.message = message;
Customer cust = new Customer();
cust.GetFromStorage(ctx);
if (!cust.LoggedIn(ctx)) {
return RedirectToAction("Index", "Authenticate");
}
ViewBag.cust = cust;
return View();
}
示例9: Index
public ActionResult Index()
{
// Instantiate our Customer object
Customer cust = new Customer();
// Retrieve from Session/Cookie
cust.GetFromStorage();
// Get the Customer record
cust.Get();
cust.BindAddresses();
ViewBag.countries = UDF.GetCountries();
ViewBag.cust = cust;
ViewBag.error = TempData["error"];
return View();
}
示例10: Add
public ActionResult Add(int id = 0, int qty = 1)
{
// Create Customer
Customer customer = new Customer();
// Retrieve Customer from Sessions/Cookie
customer.GetFromStorage();
// Add the item to the cart
if (customer.Cart.payment_id == 0) {
customer.Cart.Add(id,qty);
// Serialize the Customer back to where it came from
return RedirectToAction("Index");
} else {
UDF.ExpireCart(customer.ID);
return RedirectToAction("Index");
}
}
示例11: Index
public async Task<ActionResult> Index() {
HttpContext ctx = System.Web.HttpContext.Current;
var pcats = CURTAPI.GetParentCategoriesAsync();
await Task.WhenAll(new Task[] { pcats });
ViewBag.parent_cats = await pcats;
// Create Customer
Customer customer = new Customer();
// Retrieve Customer from Sessions/Cookie
customer.GetFromStorage(ctx);
// Create Cart object from customer
Cart cart = customer.Cart;
// Get the api response from the parts in this Cart
cart.GetParts();
ViewBag.cart = cart;
return View();
}
示例12: Initialize
protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
base.Initialize(requestContext);
// Get the vehicle years
List<double> years = CURTAPI.GetYears();
ViewBag.years = years;
// Get the parent categories
List<APICategory> parent_cats = CURTAPI.GetParentCategories();
ViewBag.parent_cats = parent_cats;
// We're gonna dump our Customer Session object out
Customer customer = new Customer();
customer.GetFromStorage();
Settings settings = new Settings();
ViewBag.settings = settings;
ViewBag.customer = customer;
}
示例13: AddAddress
public ActionResult AddAddress()
{
try {
// Create Customer
Customer customer = new Customer();
customer.GetFromStorage();
if (!customer.LoggedIn()) {
return RedirectToAction("Index", "Authenticate");
}
Address address = new Address();
// Build out our Billing object
address = new Address {
first = Request.Form["first"],
last = Request.Form["last"],
street1 = Request.Form["street1"],
street2 = (Request.Form["street2"].Trim() == "") ? null : Request.Form["street2"].Trim(),
city = Request.Form["city"],
postal_code = Request.Form["zip"],
residential = (Request.Form["residential"] == null) ? false : true,
active = true
};
try {
address.state = Convert.ToInt32(Request.Form["state"]);
} catch (Exception) {
throw new Exception("You must select a state/province.");
}
address.Save(customer.ID);
} catch (Exception e) {
if (e.Message.ToLower().Contains("a potentially dangerous")) {
throw new HttpException(403, "Forbidden");
}
}
return RedirectToAction("Addresses");
}
示例14: ChooseShipping
//[RequireHttps]
public ActionResult ChooseShipping(int id = 0) {
// Create Customer
Customer customer = new Customer();
HttpContext ctx = System.Web.HttpContext.Current;
// Retrieve Customer from Sessions/Cookie
customer.GetFromStorage(ctx);
if (customer.Cart.payment_id == 0) {
if (customer.shippingID == 0) {
customer.SetShippingDefaultAddress(id);
}
customer.Cart.SetShipping(id);
return RedirectToAction("Shipping");
} else {
UDF.ExpireCart(ctx, customer.ID);
return RedirectToAction("index");
}
}
示例15: AddShippingAddress
//[RequireHttps]
public ActionResult AddShippingAddress() {
string error = "";
try {
// Create Customer
Customer customer = new Customer();
HttpContext ctx = System.Web.HttpContext.Current;
customer.GetFromStorage(ctx);
Address shipping = new Address();
// Build out our Billing object
shipping = new Address {
first = Request.Form["sfirst"],
last = Request.Form["slast"],
street1 = Request.Form["sstreet1"],
street2 = Request.Form["sstreet2"],
city = Request.Form["scity"],
postal_code = Request.Form["szip"],
residential = (Request.Form["sresidential"] == null) ? false : true,
active = true
};
try {
shipping.state = Convert.ToInt32(Request.Form["sstate"]);
} catch (Exception) {
throw new Exception("You must select a shipping state/province.");
}
if (shipping.isPOBox()) {
throw new Exception("You cannot ship to a PO Box.");
}
//shipping.GeoLocate();
shipping.Save(customer.ID);
// Retrieve Customer from Sessions/Cookie
customer.Cart.SetShipping(shipping.ID);
} catch (Exception e) {
error = e.Message;
}
return RedirectToAction("shipping", new { error = error });
}