private topCart getGuestCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId) { httpSessionStateBase["userId"] = null; topCart helperItem = new topCart(); string guestGuid = ""; if (httpSessionStateBase["guestGuid"] != null) { guestGuid = httpSessionStateBase["guestGuid"].ToString(); if (guestGuid == "System.Web.HttpCookie" || guestGuid == "00000000-0000-0000-0000-000000000000") { guestGuid = getGuidCookieOrNew(request, response); httpSessionStateBase["guestGuid"] = guestGuid; } } else { guestGuid = getGuidCookieOrNew(request, response); } helperItem.guestGuid = guestGuid; var basketList = db.tbl_basket.Where(a => a.guestCode == guestGuid).ToList(); if (basketList != null && basketList.Count > 0) { helperItem.basketIdString = string.Join(",", basketList.Select(a => a.basketId).ToList()); helperItem.productCount = basketList.Sum(a => a.quantity); } return helperItem; }
public void errorSend(Exception ex, string msg) { string path = HttpContext.Current.Server.MapPath("~/Download/error/error.txt"); string errorText = DateTime.Now.ToString("dd.MM.yyyy") + "--" + msg + "--" + ex.Message; if (!System.IO.File.Exists(path)) { var fileCreater = System.IO.File.Create(path); fileCreater.Dispose(); } using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, true)) { file.WriteLine(errorText); } try { tbl_error item = new tbl_error(); item.saveDate = DateTime.Now; item.errorText = errorText; var dbContext = new titizOtoEntities(); dbContext.tbl_error.Add(item); dbContext.SaveChanges(); dbContext.Dispose(); } catch { } }
private void checkCookie(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, DbWithController itemController) { if (httpSessionStateBase["userId"] == null && request.Cookies["userCookie"] != null && request.Cookies["userCookie"]["userHashVal"] != null && request.Cookies["userCookie"]["userHashValTwo"] != null) { var userList = db.tbl_user.Where(a => a.registerStatuId == (int)registerStatu.registered).ToList(); tbl_user selectedUser = null; string userHashVal = request.Cookies["userCookie"]["userHashVal"]; string userHashValTwo = request.Cookies["userCookie"]["userHashValTwo"]; foreach (var item in userList) { if (item.password.Length > 6 && userHashValTwo == item.password.Substring(0, 7) && itemController.MD5(item.email).Substring(0, 7) == userHashVal) { selectedUser = item; break; } } if (selectedUser != null) { httpSessionStateBase["userId"] = selectedUser.userId.ToString(); httpSessionStateBase["userRoleId"] = selectedUser.userTypeId.ToString(); } else { response.Cookies["userCookie"].Expires = DateTime.Now.AddDays(-1); } } }
private void bindBasketAndRegisterUrl(titizOtoEntities db, int langId, topCart helperItem) { pageShared ps = new pageShared(db); var registerPage = ps.getPageByType(pageType.registerLogin, langId); if (registerPage != null) { helperItem.registerUrl = registerPage.url + ".html"; } var basketPage = ps.getPageByType(pageType.basket, langId); if (basketPage != null) { helperItem.basketUrl = basketPage.url + ".html"; } }
public checkoutShared(titizOtoEntities db) { this.db = db; }
public pageShared(titizOtoEntities db) { this.db = db; }
public DbConnector() { db = new titizOtoEntities(); db.Configuration.LazyLoadingEnabled = true; }
public productShared(titizOtoEntities db) { this.db = db; }
public mailShared(titizOtoEntities db, int langId) { this.db = db; this.langId = langId; }
public basketShared(titizOtoEntities db) { this.db = db; }
public discountShared(titizOtoEntities db) { this.db = db; }
private topCart getUserCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId) { int userId = 0; topCart helperItem = new topCart(); if (int.TryParse(httpSessionStateBase["userId"].ToString(), out userId)) { var userItem = db.tbl_user.Where(a => a.userId == userId).FirstOrDefault(); if (userItem != null) { helperItem.isRegisteredUser = true; helperItem.userId = userId; helperItem.nameSurname = userItem.name + " " + userItem.surname; helperItem.guestGuid = null; helperItem.userGuid = userItem.guid; var cartList = db.tbl_basket.Where(a => a.userId == userId).ToList(); if (cartList != null && cartList.Count > 0) { helperItem.basketIdString = string.Join(",", cartList.Select(a => a.basketId).ToList()); helperItem.productCount = cartList.Sum(a => a.quantity); } else { helperItem.productCount = 0; } return helperItem; } } return null; }
private topCart getTopCartItem(titizOtoEntities db, HttpSessionStateBase httpSessionStateBase, HttpRequestBase request, HttpResponseBase response, int langId) { topCart helperItem = new topCart(); bool isGuest = true; if (httpSessionStateBase["userId"] != null) { helperItem = getUserCartItem(db, httpSessionStateBase, request, response, langId); if (helperItem != null) { isGuest = false; } } if (isGuest) { helperItem = getGuestCartItem(db, httpSessionStateBase, request, response, langId); } bindBasketAndRegisterUrl(db, langId, helperItem); return helperItem; }
public DbWithController() { dbWithBasicFunction = new DbWithBasicFunction(); db = dbWithBasicFunction.db; }
public addressShared(titizOtoEntities db) { this.db = db; }
public userShared(titizOtoEntities db) { this.db = db; }