private void AddVisitedProducts(int productId) { string ipAddress = IpAddress.GetLocalIPAddress(); using (var ctx = new RachnaDBContext()) { Product _prd = ctx.Product.Where(m => m.Product_Id == productId).FirstOrDefault(); VisitedProducts vpdts = ctx.VisitedProducts.Where(m => m.Product_Id == productId && m.IpAddress == ipAddress).FirstOrDefault(); if (_prd != null) { _prd.ProductBanner = ctx.ProductBanner.Where(m => m.Product_Id == _prd.Product_Id).ToList(); VisitedProducts _customerVisitedProducts = new VisitedProducts() { IpAddress = IpAddress.GetLocalIPAddress(), Product_Id = productId, Store_Id = _prd.Store_Id, ProductTitle = _prd.Product_Title, ProductBanner = _prd.ProductBanner.Where(m => m.Product_Banner_Default == 1).FirstOrDefault().Product_Banner_Photo, DateCreated = DateTime.Now, VisitedCount = 1 }; if (vpdts == null) { ctx.VisitedProducts.Add(_customerVisitedProducts); ctx.SaveChanges(); } else { vpdts.VisitedCount = vpdts.VisitedCount + 1; ctx.Entry(vpdts).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } } }; }
public void UpdateCart(string id, string qty, string size) { int prdId = Convert.ToInt32(id); Product _product = bProduct.List().Where(m => m.Product_Id == prdId).FirstOrDefault(); if (HttpContext.Current.Session["UserKey"] != null) { int custId = Convert.ToInt32(HttpContext.Current.Session["UserKey"].ToString()); Customers _customer = bCustomer.List().Where(m => m.Customer_Id == custId).FirstOrDefault(); Carts _cart = bCarts.List().ToList().Where(m => m.Customer_Id == _customer.Customer_Id && m.Product_Id == prdId && m.Cart_Status == eCartStatus.Open.ToString()).FirstOrDefault(); _cart.Cart_Qty = qty != "0"?Convert.ToInt32(qty):_cart.Cart_Qty; _cart.Cart_Size = size != "0" ? size : _cart.Cart_Size; _cart.Cart_Price = (Convert.ToInt32(qty) * _product.Product_Our_Price); DeleteCart(id); _cart.DateUpdated = DateTime.Now; SaveCartToDB(_cart); } else { Carts _cart = bCarts.List().ToList().Where(m => m.Ip_Address == IpAddress.GetLocalIPAddress() && m.Product_Id == prdId && m.Cart_Status == eCartStatus.Temp.ToString()).FirstOrDefault(); _cart.Cart_Qty = qty != "0" ? Convert.ToInt32(qty) : _cart.Cart_Qty; _cart.Cart_Size = size != "0" ? size : _cart.Cart_Size; _cart.Cart_Price = (Convert.ToInt32(qty) * _product.Product_Our_Price); _cart.DateUpdated = DateTime.Now; DeleteCart(id); SaveCartToDB(_cart); } }
public ActionResult LoginUser(Customers _customer) { Customers _cust = bCustomer.List().Where(m => m.Customers_EmailId == _customer.Customers_EmailId && PasswordProtect.Decrypt(m.Customers_Password) == _customer.Customers_Password && m.Customers_Status == eStatus.Active.ToString()).FirstOrDefault(); if (_cust != null) { string ipAddress = IpAddress.GetLocalIPAddress(); Session["UserKey"] = _cust.Customer_Id.ToString(); Carts _carts = bCarts.List().Where(m => m.Ip_Address == ipAddress && m.Cart_Status == eCartStatus.Temp.ToString()).FirstOrDefault(); if (_carts != null) { TempData["SaveAfterLogin"] = 200; } else { Session["redirectUrl"] = null; } return(Redirect("/user/index")); } else { TempData["Message"] = "Oops!! Login failed due to invalid userid/password or your EmailId is Not verified.. Please try with valid userid/password or Click activation link to activate your account."; return(RedirectToAction("login", _customer)); } }
private void AddSearchKey(string searchKey) { using (var ctx = new RachnaDBContext()) { CustomerSearchKey _customerSearchKey = new CustomerSearchKey() { IpAddress = IpAddress.GetLocalIPAddress(), SearchKey = searchKey, DateCreated = DateTime.Now }; ctx.CustomerSearchKey.Add(_customerSearchKey); ctx.SaveChanges(); }; }
public void TestMultiChainStartServerProcess() { // Setup var processWrapper = new ProcessWrapper { Mock = true, ReplyMessage = "Blockchain test" }; var chain = new MultiChainProcess(null, processWrapper); var ipAddress = IpAddress.GetLocalIPAddress(); // Test var str = chain.StartServerProcess(); // Check Assert.AreEqual("Blockchain test", str); Assert.AreEqual($"/c D:\\Development\\Eigenbouw\\bc\\MultiChain\\multichaind.exe testchain@{ipAddress}:1987 -daemon", processWrapper.ProcessInfo.Arguments); }
public ActionResult CustomerRequest(CustomerRequest customerRequest) { string result = string.Empty; using (var ctx = new RachnaDBContext()) { CustomerRequest _customerRequest = new CustomerRequest() { FullName = customerRequest.FullName, EmailId = customerRequest.EmailId, Subject = customerRequest.Subject, Description = customerRequest.Description, IpAddress = IpAddress.GetLocalIPAddress(), DateCreated = DateTime.Now, DateUpdated = DateTime.Now }; ctx.CustomerRequest.Add(_customerRequest); ctx.SaveChanges(); result = "Thank you for submitting your request we will work on your request."; } return(Json(result, JsonRequestBehavior.AllowGet)); }
public void AddToCart(string id, string qty, string size) { int prdId = Convert.ToInt32(id); Product _product = bProduct.List().Where(m => m.Product_Id == prdId).FirstOrDefault(); if (HttpContext.Current.Session["UserKey"] != null) { int custId = Convert.ToInt32(HttpContext.Current.Session["UserKey"].ToString()); Carts _carts = bCarts.List().ToList().Where(m => m.Customer_Id == custId && m.Product_Id == Convert.ToInt32(id) && m.Cart_Status == eCartStatus.Open.ToString()).FirstOrDefault(); Customers _customer = bCustomer.List().Where(m => m.Customer_Id == custId).FirstOrDefault(); Carts _cart = new Carts(); _cart.Customer_Id = 000; _cart.Product_Id = Convert.ToInt32(id); _cart.Cart_Qty = (Convert.ToInt32(qty) == 1 && _carts != null) ? (Convert.ToInt32(qty) + _carts.Cart_Qty) : Convert.ToInt32(qty); _cart.Cart_Size = size; _cart.Cart_Price = (_cart.Cart_Qty * _product.Product_Our_Price); _cart.Cart_Status = eCartStatus.Open.ToString(); _cart.Product_Banner = _product.ProductBanner.Where(m => m.Product_Banner_Default == 1).FirstOrDefault().Product_Banner_Photo; _cart.Product_Price = _product.Product_Our_Price; _cart.Shipping_Charge = _product.Product_ShippingCharge; _cart.Cart_Total_Price = _cart.Cart_Price + _cart.Shipping_Charge; _cart.Product_Title = _product.Product_Title; _cart.Customer_Id = _customer.Customer_Id; _cart.Customer_Name = _customer.Customers_FullName; _cart.Store_Id = _product.Store_Id; _cart.DateCreated = DateTime.Now; _cart.DateUpdated = DateTime.Now; if (_carts != null) { DeleteCart(id); } SaveCartToDB(_cart); } else { Carts _carts = bCarts.List().ToList().Where(m => m.Ip_Address == IpAddress.GetLocalIPAddress() && m.Product_Id == Convert.ToInt32(id) && m.Cart_Status == eCartStatus.Temp.ToString()).FirstOrDefault(); Customers _customer = bCustomer.List().Where(m => m.Customer_Id == 1).FirstOrDefault(); Carts _cart = new Carts(); _cart.Customer_Id = 000; _cart.Product_Id = Convert.ToInt32(id); _cart.Cart_Qty = (Convert.ToInt32(qty) == 1 && _carts != null) ? (Convert.ToInt32(qty) + _carts.Cart_Qty) : Convert.ToInt32(qty); _cart.Cart_Size = size; _cart.Cart_Price = (_cart.Cart_Qty * _product.Product_Our_Price); _cart.Cart_Status = eCartStatus.Temp.ToString(); _cart.Product_Banner = _product.ProductBanner.Where(m => m.Product_Banner_Default == 1).FirstOrDefault().Product_Banner_Photo; _cart.Product_Price = _product.Product_Our_Price; _cart.Shipping_Charge = _product.Product_ShippingCharge; _cart.Cart_Total_Price = _cart.Cart_Price + _cart.Shipping_Charge; _cart.Product_Title = _product.Product_Title; _cart.Customer_Id = _customer.Customer_Id; _cart.Customer_Name = _customer.Customers_FullName; _cart.Ip_Address = IpAddress.GetLocalIPAddress(); _cart.Store_Id = _product.Store_Id; _cart.DateCreated = DateTime.Now; _cart.DateUpdated = DateTime.Now; if (_carts != null) { DeleteCart(id); } SaveCartToDB(_cart); } }
public List <Carts> GetCarts() { List <Carts> _carts = new List <Carts>(); if (HttpContext.Current.Session["UserKey"] != null) { int cusId = Convert.ToInt32(HttpContext.Current.Session["UserKey"]); _carts = bCarts.List().ToList().Where(m => m.Customer_Id == cusId && m.Cart_Status == eCartStatus.Open.ToString()).ToList(); } else { _carts = bCarts.List().ToList().ToList().Where(x => x.Cart_Status == eCartStatus.Temp.ToString() && x.Ip_Address == IpAddress.GetLocalIPAddress()).ToList(); } if (_carts != null) { foreach (var item in _carts) { item.Products = bProduct.List().Where(m => m.Product_Id == item.Product_Id).FirstOrDefault(); } } return(_carts); }
public void SaveCartAfterLogin() { if (HttpContext.Current.Session["UserKey"] != null) { int custId = Convert.ToInt32(HttpContext.Current.Session["UserKey"].ToString()); Customers Customers = bCustomer.List().Where(m => m.Customer_Id == custId).FirstOrDefault(); List <Carts> Carts = bCarts.List().ToList().Where(x => x.Cart_Status == eCartStatus.Temp.ToString() && x.Ip_Address == IpAddress.GetLocalIPAddress()).ToList(); List <Carts> matching = null; foreach (var item in Carts) { matching = Customers.Cart.Where(m => m.Product_Id == item.Product_Id && m.Cart_Status == eCartStatus.Open.ToString()).ToList(); if (matching != null && matching.Count > 0) { using (var context = new RachnaDBContext()) { context.Entry(matching).State = EntityState.Deleted; context.SaveChanges(); } } } foreach (var item in Carts) { DeleteCart(item.Product_Id.ToString()); Carts ncarts = new Carts() { Cart_Price = item.Cart_Price, Cart_Qty = item.Cart_Qty, Cart_Size = item.Cart_Size, Cart_Status = eCartStatus.Open.ToString(), Cart_Total_Price = item.Cart_Total_Price, Customer_Id = Customers.Customer_Id, Customer_Name = Customers.Customers_FullName, Store_Id = item.Store_Id, Shipping_Charge = item.Shipping_Charge, DateCreated = item.DateCreated, DateUpdated = DateTime.Now, Ip_Address = item.Ip_Address, Product_Title = item.Product_Title, Product_Price = item.Product_Price, Product_Id = item.Product_Id, Product_Banner = item.Product_Banner }; SaveCartToDB(ncarts); } } }
public void DeleteCart(string id) { int prdId = Convert.ToInt32(id); if (HttpContext.Current.Session["UserKey"] != null) { int custId = Convert.ToInt32(HttpContext.Current.Session["UserKey"].ToString()); Customers _customer = bCustomer.List().Where(m => m.Customer_Id == custId).FirstOrDefault(); Carts _cart = bCarts.List().ToList().Where(m => m.Product_Id == prdId && (m.Cart_Status == eCartStatus.Open.ToString() || m.Cart_Status == eCartStatus.Temp.ToString())).FirstOrDefault(); if (_cart != null) { using (var context = new RachnaDBContext()) { context.Entry(_cart).State = EntityState.Deleted; context.SaveChanges(); } } } else { Carts _cart = bCarts.List().ToList().Where(m => m.Product_Id == prdId && (m.Cart_Status == eCartStatus.Open.ToString() || m.Cart_Status == eCartStatus.Temp.ToString()) && m.Ip_Address == IpAddress.GetLocalIPAddress()).FirstOrDefault(); if (_cart != null) { using (var context = new RachnaDBContext()) { context.Entry(_cart).State = EntityState.Deleted; context.SaveChanges(); } } } }
public ActionResult SubmitAsGuest(Customers _customer, CustomerAddress _address) { Customers cust = bCustomer.List().Where(m => m.Customers_EmailId == _customer.Customers_EmailId || m.Customers_Phone == _customer.Customers_Phone).FirstOrDefault(); if (cust == null) { Customers Customer = new Customers() { Customers_FullName = _customer.Customers_FullName, Customers_Description = "test description", Customers_EmailId = _customer.Customers_EmailId, Customers_Phone = _customer.Customers_Phone, Customers_Photo = "images/user_icon.png", Customers_Login_Attempt = 0, Customers_CreatedDate = DateTime.Now, Customers_UpdatedDate = DateTime.Now, Customers_Password = _customer.Customers_Password, Customers_Status = eStatus.Active.ToString(), IsEmailVerified = 0, CustomerType = eCustomerType.guest.ToString() }; Customer = bCustomer.Create(Customer); if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"])) { string host = ConfigurationSettings.AppSettings["DomainUrl"].ToString(); host = host + "/user/VerifyEmail?VerificationId=" + Customer.CustomerCode + "&reirect-url=ghgfhsgf798798jhshfjsfkjs.html"; string body = MailHelper.VerifyEmailLink(host, Customer.Customers_FullName); MailHelper.SendEmail(Customer.Customers_EmailId, "Verify Your EmailId", body, "Rachna Teracotta Store"); } CustomerAddress CustomerAddres = new CustomerAddress() { Customer_Id = Customer.Customer_Id, Customer_AddressLine1 = _address.Customer_AddressLine1, Customer_AddressLine2 = _address.Customer_AddressLine2, CustomerAddress_LandMark = _address.CustomerAddress_LandMark, CustomerAddress_City = _address.CustomerAddress_City, CustomerAddress_State = _address.CustomerAddress_State, CustomerAddress_Country = _address.CustomerAddress_Country, CustomerAddress_ZipCode = _address.CustomerAddress_ZipCode, CustomerAddress_DateCreated = DateTime.Now, CustomerAddress_DateUpdated = DateTime.Now, CustomerAddress_Status = _address.CustomerAddress_Status }; CustomerAddres = bCustomer.CreateAddress(CustomerAddres); Carts _carts = _mcartmdl.GetCarts().Where(m => m.Ip_Address == IpAddress.GetLocalIPAddress() && m.Cart_Status == eCartStatus.Temp.ToString()).FirstOrDefault(); Session["UserKey"] = Customer.Customer_Id.ToString(); if (_carts != null) { _mcartmdl.SaveCartAfterLogin(); } return(Redirect("/user/paymentmethod")); } else { TempData["Message"] = "Oops!! entered customer email/phone already exists.please try with different emailid/phone."; } return(Redirect("/user/guestcheckin")); }