Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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
            {

            }
        }
Ejemplo n.º 3
0
        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);

                }

            }
        }
Ejemplo n.º 4
0
        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";
            }
        }
Ejemplo n.º 5
0
 public checkoutShared(titizOtoEntities db)
 {
     this.db = db;
 }
Ejemplo n.º 6
0
 public pageShared(titizOtoEntities db)
 {
     this.db = db;
 }
Ejemplo n.º 7
0
 public DbConnector()
 {
     db = new titizOtoEntities();
     db.Configuration.LazyLoadingEnabled = true;
 }
Ejemplo n.º 8
0
 public productShared(titizOtoEntities db)
 {
     this.db = db;
 }
Ejemplo n.º 9
0
 public mailShared(titizOtoEntities db, int langId)
 {
     this.db = db;
     this.langId = langId;
 }
Ejemplo n.º 10
0
 public basketShared(titizOtoEntities db)
 {
     this.db = db;
 }
Ejemplo n.º 11
0
 public discountShared(titizOtoEntities db)
 {
     this.db = db;
 }
Ejemplo n.º 12
0
        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;
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
 public DbWithController()
 {
     dbWithBasicFunction = new DbWithBasicFunction();
     db = dbWithBasicFunction.db;
 }
Ejemplo n.º 15
0
 public addressShared(titizOtoEntities db)
 {
     this.db = db;
 }
Ejemplo n.º 16
0
 public userShared(titizOtoEntities db)
 {
     this.db = db;
 }