protected void btnSubmit_Click(object sender, EventArgs e) { try { int id = Convert.ToInt32(hdnSliderId.Value); Sliders Sliders = context.Slider.Where(m => m.Slider_Id == id).FirstOrDefault(); Sliders.Slider_TItle = txtTitle.Text; Sliders.Slider_Description = txtDescription.Text; Sliders.ButtonText = txtBtnTitle.Text; Sliders.Slider_RedirectUrl = txtImageUrl.Text; Sliders.Slider_UpdatedDate = DateTime.Now; Sliders.Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()]); context.Entry(Sliders).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); Response.Redirect("/administration/home/slider.aspx?id=2000&redirecturl=admin-slider-RachnaTeracotta"); } catch (Exception ex) { pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = ex.Message; } }
internal ContactOwner Create(ContactOwner ContactOwner) { try { int maxContactOwnerId = 1; if (context.ContactOwner.ToList().Count > 0) { maxContactOwnerId = context.ContactOwner.Max(m => m.Contact_Owner_Id); } maxContactOwnerId = (maxContactOwnerId == 1 && context.ContactOwner.ToList().Count > 0) ? (maxContactOwnerId + 1) : maxContactOwnerId; ContactOwner.Contact_Owner_Code = "RT" + maxContactOwnerId + "CTOCODE" + (maxContactOwnerId + 1); if (ContactOwner.Contact_Status == eStatus.Active.ToString()) { List <ContactOwner> _ContactOwner = context.ContactOwner.ToList(); foreach (var item in _ContactOwner) { item.Contact_Status = eStatus.InActive.ToString(); context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } context.ContactOwner.Add(ContactOwner); context.SaveChanges(); return(ContactOwner); } catch (Exception ex) { ContactOwner.ErrorMessage = ex.Message; return(ContactOwner); } }
internal Logo Create(Logo Logo) { try { int maxLogoId = 1; if (context.Logo.ToList().Count > 0) { maxLogoId = context.Logo.Max(m => m.Logo_Id); } maxLogoId = (maxLogoId == 1 && context.Logo.ToList().Count > 0) ? (maxLogoId + 1) : maxLogoId; Logo.LogoCode = "RT" + maxLogoId + "LOGCODE" + (maxLogoId + 1); if (Logo.Logo_Status == eStatus.Active.ToString()) { List <Logo> _Logo = context.Logo.ToList(); foreach (var item in _Logo) { item.Logo_Status = eStatus.InActive.ToString(); context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } context.Logo.Add(Logo); context.SaveChanges(); return(Logo); } catch (Exception ex) { Logo.ErrorMessage = ex.Message; return(Logo); } }
internal MetaInformation Create(MetaInformation MetaInformation) { try { int maxMetaInformationId = 1; if (context.MetaInformation.ToList().Count > 0) { maxMetaInformationId = context.MetaInformation.Max(m => m.Meta_Id); } maxMetaInformationId = (maxMetaInformationId == 1 && context.MetaInformation.ToList().Count > 0) ? (maxMetaInformationId + 1) : maxMetaInformationId; MetaInformation.Meta_Code = "RT" + maxMetaInformationId + "MTCODE" + (maxMetaInformationId + 1); if (MetaInformation.Meta_Status == eStatus.Active.ToString()) { List <MetaInformation> _MetaInformation = context.MetaInformation.ToList(); foreach (var item in _MetaInformation) { item.Meta_Status = eStatus.InActive.ToString(); context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } context.MetaInformation.Add(MetaInformation); context.SaveChanges(); return(MetaInformation); } catch (Exception ex) { MetaInformation.ErrorMessage = ex.Message; return(MetaInformation); } }
internal UnderConstrunction Create(UnderConstrunction UnderConstrunction) { try { int maxUnderConstrunctionId = 1; if (context.UnderConstrunction.ToList().Count > 0) { maxUnderConstrunctionId = context.UnderConstrunction.Max(m => m.UnderConst_Id); } maxUnderConstrunctionId = (maxUnderConstrunctionId == 1 && context.UnderConstrunction.ToList().Count > 0) ? (maxUnderConstrunctionId + 1) : maxUnderConstrunctionId; UnderConstrunction.UnderConstCode = "RT" + maxUnderConstrunctionId + "UNDCNSTCODE" + (maxUnderConstrunctionId + 1); if (UnderConstrunction.UnderConst_Status == eStatus.Active.ToString()) { List <UnderConstrunction> _UnderConstrunction = context.UnderConstrunction.ToList(); foreach (var item in _UnderConstrunction) { item.UnderConst_Status = eStatus.InActive.ToString(); context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } context.UnderConstrunction.Add(UnderConstrunction); context.SaveChanges(); return(UnderConstrunction); } catch (Exception ex) { UnderConstrunction.ErrorMessage = ex.Message; return(UnderConstrunction); } }
public ActionResult VerifyEmail(string VerificationId) { Customers _cust = bCustomer.List().Where(m => m.CustomerCode == VerificationId).FirstOrDefault(); if (_cust != null) { if (_cust.IsEmailVerified != 1) { _cust.IsEmailVerified = 1; _cust.Customers_UpdatedDate = DateTime.Now; _cust.Customers_Status = eStatus.Active.ToString(); context.Entry(_cust).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(Redirect("/user/emailVerified?id=100&redirect-url=hgvvnb798798Vhgfhfhhghgh.html")); } else { return(Redirect("/user/emailVerified?id=404&redirect-url=hgvvnb798798Vhgfhfhhghgh.html")); } } else { return(Redirect("/user/emailVerified?id=404&redirect-url=hgvvnb798798Vhgfhfhhghgh.html")); } }
internal Carts Update(Carts Carts) { try { context.Entry(Carts).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(Carts); } catch (Exception ex) { Carts.ErrorMessage = ex.Message; return(Carts); } }
internal SocialNetworking Update(SocialNetworking SocialNetworking) { try { context.Entry(SocialNetworking).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(SocialNetworking); } catch (Exception ex) { SocialNetworking.ErrorMessage = ex.Message; return(SocialNetworking); } }
internal Functionality Update(Functionality Functionality) { try { context.Entry(Functionality).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(Functionality); } catch (Exception ex) { Functionality.ErrorMessage = ex.Message; return(Functionality); } }
protected void btnSubmit_Click(object sender, EventArgs e) { int Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()); int offerId = Convert.ToInt32(hdnOfferId.Value); Offers Offers1 = context.Offers.Where(m => m.Offer_Id == offerId).FirstOrDefault(); Offers1.Offer_On = ddlOffersFor.Text; Offers1.Offer_Title = txtOfferTitle.Text; Offers1.Offer_Description = txtDescription.Text; Offers1.Offer_StartsDate = Convert.ToDateTime(txtStartDate.Text); Offers1.Offer_EndDate = Convert.ToDateTime(txtEndDate.Text); Offers1.TotNumbers = Convert.ToInt32(txNoOfTimes.Text); Offers1.Offer_UpdateDate = DateTime.Now; Offers1.Administrators_Id = Administrators_Id; Offers1.Product_Id = (ddlOffersFor.Text == "Product") ? Convert.ToInt32(ddlOfferValue.SelectedValue) : 0; Offers1.Category_Id = (ddlOffersFor.Text == "Category") ? Convert.ToInt32(ddlOfferValue.SelectedValue) : 0; Offers1.Store_Id = Convert.ToInt32(ddlStore.SelectedValue); if (imgInp.HasFile) { if (imgInp.HasFile) { string filename = "Offers_" + GetRandomNumber(1, 200) + "_ofs.png"; string folderPath = "files/offers/"; Offers1.Offer_Banner = folderPath + filename; string path = Server.MapPath("../" + Offers1.Offer_Banner); FileInfo file = new FileInfo(path); if (file.Exists && Offers1.Offer_Banner != "content/noimage.png")//check file exsit or not { file.Delete(); } Upload(filename); } Offers1.Offer_Code = "OFRRACH" + Offers1.Offer_Id + "TERA" + (Offers1.Offer_Id + 1); context.Entry(Offers1).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } else { Offers1.Offer_Code = "OFRRACH" + Offers1.Offer_Id + "TERA" + (Offers1.Offer_Id + 1); context.Entry(Offers1).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } LoadDetail(Offers1.Offer_Id.ToString()); Response.Redirect("/administration/offers/offers.aspx?id=100&redirect-url=uyiretieyt7985798435ihtiuertireyte&id-red=alladmin.html"); }
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(); } } }; }
protected void btnSubmit_Click(object sender, EventArgs e) { int Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()); int pageId = Convert.ToInt32(hdnPageId.Value); Pages Pages = context.Pages.Where(m => m.Page_Id == pageId).FirstOrDefault(); Pages.Administrators_Id = Administrators_Id; Pages.Title = txtOfferTitle.Text; Pages.Description = txtSmallDescription.Text; Pages.DateUpdated = DateTime.Now; context.Entry(Pages).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); Response.Redirect("/administration/pages/allpages.aspx?id=100&redirect-url=uyiretieyt7985798435ihtiuertireyte&id-red=alladmin.html"); }
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(); } } } }
protected void Button1_Click(object sender, EventArgs e) { try { using (var ctx = new RachnaDBContext()) { ProdComments ProdComments = new ProdComments(); int commentId = Convert.ToInt32(hdnProductCommentId.Value); ProdComments = ctx.ProdComments.ToList().Where(m => m.Comment_Id == commentId).FirstOrDefault(); if (ProdComments != null) { ProdComments.Comment_Status = ddlSorderStatus.Text; ProdComments.DateUpdated = DateTime.Now; ctx.Entry(ProdComments).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Comment Detail Updated Successfully and status set to " + ddlSorderStatus.Text; } } } catch (Exception ex) { pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = ex.Message; } }
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e) { try { int prdFeatId = Convert.ToInt32(e.Values[0].ToString()); ProductFeatures _banner = context.ProductFeature.Where(m => m.Product_Feature_Id == prdFeatId).FirstOrDefault(); context.Entry(_banner).State = System.Data.Entity.EntityState.Deleted; context.SaveChanges(); LoadDetail(); pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Product Feature Deleted Successfully."; pnlProduct.Visible = false; } catch (Exception ex) { pnlProduct.Visible = false; pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = ex.Message; } }
protected void btnApprove_Click(object sender, EventArgs e) { int AdminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()); Administrators _admin = context.Administrator.ToList().Where(m => m.Administrators_Id == AdminId).FirstOrDefault(); int prdId = Convert.ToInt32(lblProductId.Text); Product _Product = context.Product.ToList().Where(m => m.Product_Id == prdId).FirstOrDefault(); List <ProductBanners> ProductBanners = context.ProductBanner.Where(m => m.Product_Id == _Product.Product_Id).ToList(); if (ProductBanners.Count() > 1 && (!(ProductBanners[0].Product_Banner_Photo == "content/noimage.png" && ProductBanners[0].Product_Banner_Default == 1))) { string currentStatus = _Product.Product_Status; if (_Product.Product_Status != eProductStatus.Published.ToString()) { _Product.Product_Status = ProductHelper.GetProductStatus(currentStatus); context.Entry(_Product).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); ProductHelper.CreateProductFlow(_Product.Product_Id, _Product.Product_Title, _admin.Administrators_Id, _admin.FullName, "Product Updated from" + currentStatus + " to " + _Product.Product_Status, _Product.Product_Status); LoadDetail(_Product.Product_Id.ToString()); pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Success!!! Product Updated Successfully and Product Status Set to " + _Product.Product_Status + " Status, from " + currentStatus + " Status"; } else { pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Oops!!! You cannot Update the product status to " + _Product.Product_Status + " from " + currentStatus + " Because, Product status is in published status. You can reject the product."; } } else { pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Oops!!! You cannot Update the product status to " + _Product.Product_Status + " Because, there is no enough product banner available(Bnner should not be no image banner and also allease Minimum two banners required). Product should not have default banner."; } }
public void DeleteCartByCartId(Carts _cart) { using (var context = new RachnaDBContext()) { context.Entry(_cart).State = EntityState.Deleted; context.SaveChanges(); } }
protected void btnSubmit_Click(object sender, EventArgs e) { string result = Upload(hdnProdId.Value); if (result == "100") { int prdId = Convert.ToInt32(hdnProdId.Value); ProductBanners currentBanner = context.ProductBanner.Where(m => m.Product_Id == prdId).FirstOrDefault(); ProductBanners Product = new ProductBanners() { Product_Id = Convert.ToInt32(hdnProdId.Value), Product_Banner_Photo = "files/product/" + hdnProdId.Value + "/" + hdnProdId.Value + "_" + imgInp.FileName, Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()), Product_Banner_Default = Convert.ToInt32(ddlStatus.SelectedValue), Product_Banner_CreatedDate = DateTime.Now, Product_Banner_UpdatedDate = DateTime.Now }; if (Product.Product_Banner_Default == 1) { List <ProductBanners> Productbnrs = context.ProductBanner.Where(m => m.Product_Id == prdId).ToList(); foreach (var item in Productbnrs) { item.Product_Banner_Default = 0; context.Entry(item).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); } } else { if (currentBanner == null) { Product.Product_Banner_Default = 1; } } int maxBnrAdminId = 1; if (context.ProductBanner.ToList().Count > 0) { maxBnrAdminId = context.ProductBanner.Max(m => m.Product_Id); } maxBnrAdminId = (maxBnrAdminId == 1 && context.ProductBanner.ToList().Count > 0) ? (maxBnrAdminId + 1) : maxBnrAdminId; Product.Product_BannerCode = "PRDBNRTRACH" + maxBnrAdminId + "TERA" + (maxBnrAdminId + 1); context.ProductBanner.Add(Product); context.SaveChanges(); LoadGrid(); pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Success!!! Banner Created Successfully."; ddlStatus.SelectedIndex = 0; } }
protected void OnRowDeleting(object sender, GridViewDeleteEventArgs e) { try { using (var ctx = new RachnaDBContext()) { ProductBanners _banner = ctx.ProductBanner.ToList().Where(m => m.Product_Banner_Id == Convert.ToInt32(e.Values[0].ToString())).FirstOrDefault(); string filePath = Server.MapPath("~/" + _banner.Product_Banner_Photo); if (!filePath.Contains("noimage.png")) { FileInfo file = new FileInfo(filePath); if (file.Exists) { file.Delete(); } } ctx.Entry(_banner).State = EntityState.Deleted; ctx.SaveChanges(); ProductBanners currentBanner = ctx.ProductBanner.ToList().Where(m => m.Product_Id == Convert.ToInt32(hdnProductId.Value)).FirstOrDefault(); if (currentBanner != null) { currentBanner.Product_Banner_Default = 1; ctx.Entry(currentBanner).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Product Slider Deleted Successfully."; LoadGrid(); } } catch (Exception ex) { pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Oops!! Server error occured, please contact administrator."; } }
internal SubCategories Update(SubCategories SubCategories) { try { var entity = context.SubCategory.Where(c => c.SubCategory_Id == SubCategories.SubCategory_Id).AsQueryable().FirstOrDefault(); if (entity == null) { context.SubCategory.Add(SubCategories); } else { context.Entry(entity).CurrentValues.SetValues(SubCategories); } context.SaveChanges(); return(SubCategories); } catch (Exception ex) { SubCategories.ErrorMessage = ex.Message; return(SubCategories); } }
internal Product Update(Product Product) { try { var entity = context.Product.Where(c => c.Product_Id == Product.Product_Id).AsQueryable().FirstOrDefault(); if (entity == null) { context.Product.Add(Product); } else { context.Entry(entity).CurrentValues.SetValues(Product); } context.SaveChanges(); return(Product); } catch (Exception ex) { Product.ErrorMessage = ex.Message; return(Product); } }
protected void btnSubmit_Click(object sender, EventArgs e) { try { using (var ctx = new RachnaDBContext()) { Order _productOrder = new Order(); _productOrder = ctx.Orders.ToList().Where(m => m.Order_Id == Convert.ToInt32(hdnOrderId.Value)).FirstOrDefault(); if (_productOrder != null) { if (_productOrder.Order_Status != eOrderStatus.Cancelled.ToString() || _productOrder.Order_Status != eOrderStatus.Packed.ToString() || _productOrder.Order_Status != eOrderStatus.Shipped.ToString()) { string[] listSize = hdnAvailableSize.Value.Split(','); bool sizeSame = false; foreach (var item in listSize) { if (txtSize.Text == item) { sizeSame = true; } } if (sizeSame == true) { _productOrder.Order_Size = txtSize.Text; ctx.Entry(_productOrder).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('Size Added Successfully.', { title: 'Success!! ' });", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('Selected size not in the available list', { title: 'Failed!! ' });", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is not valid.', { title: 'Failed!! ' });", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('You cannot update the product because no Size available, for this product', { title: 'Failed!! ' });", true); } } } catch (Exception ex) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('" + ex.Message + "', { title: 'Error!! ' });", true); } }
internal DealOfTheDay Update(DealOfTheDay DealOfTheDay) { try { context.Entry(DealOfTheDay).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(DealOfTheDay); } catch (Exception ex) { DealOfTheDay.ErrorMessage = ex.Message; return(DealOfTheDay); } }
public Invitations Update(Invitations invitations) { try { context.Entry(invitations).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(invitations); } catch (Exception ex) { invitations.ErrorMessage = ex.Message; return(invitations); } }
public Stores Update(Stores stores) { try { context.Entry(stores).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(stores); } catch (Exception ex) { stores.ErrorMessage = ex.Message; return(stores); } }
internal Customers Update(Customers Customers) { try { Customers.Customers_Password = PasswordProtect.Encrypt(Customers.Customers_Password); var entity = context.Customer.Where(c => c.Customer_Id == Customers.Customer_Id).AsQueryable().FirstOrDefault(); if (entity == null) { context.Customer.Add(Customers); } else { context.Entry(entity).CurrentValues.SetValues(Customers); } context.SaveChanges(); return(Customers); } catch (Exception ex) { Customers.ErrorMessage = ex.Message; return(Customers); } }
public string SetDefaultImage(string id) { using (var ctx = new RachnaDBContext()) { List <ProductBanners> Productbnrs = ctx.ProductBanner.ToList().Where(f => f.Product_Id == Convert.ToInt32(hdnProductId.Value)).ToList(); foreach (var item in Productbnrs) { item.Product_Banner_Default = 0; ctx.Entry(item).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); } ProductBanners _banner = ctx.ProductBanner.ToList().Where(m => m.Product_Banner_Id == Convert.ToInt32(id)).FirstOrDefault(); _banner.Product_Banner_Default = 1; ctx.Entry(_banner).State = System.Data.Entity.EntityState.Modified; ctx.SaveChanges(); pnlErrorMessage.Attributes.Remove("class"); pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable"; pnlErrorMessage.Visible = true; lblMessage.Text = "Banner Updated Successfully."; } LoadGrid(); return(""); }
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 Administrators Update(Administrators administrators) { try { administrators.Password = PasswordProtect.Encrypt(administrators.Password); var entity = context.Administrator.Where(c => c.Administrators_Id == administrators.Administrators_Id).AsQueryable().FirstOrDefault(); if (entity == null) { context.Administrator.Add(administrators); } else { context.Entry(entity).CurrentValues.SetValues(administrators); } context.SaveChanges(); return(administrators); } catch (Exception ex) { administrators.ErrorMessage = ex.Message; return(administrators); } }
protected void Button1_Click(object sender, EventArgs e) { string _res = string.Empty; using (var ctx = new RachnaDBContext()) { int productId = Convert.ToInt32(hdnOrderId.Value); Order _productOrder = new Order(); _productOrder = ctx.Orders.ToList().Where(m => m.Order_Id == productId).FirstOrDefault(); if (_productOrder.Order_Status != eOrderStatus.Rejected.ToString()) { if (_productOrder.Order_Status != ddlSorderStatus.Text) { if (_productOrder.Order_Status == eOrderStatus.Approved.ToString() && ddlSorderStatus.Text == eOrderStatus.Placed.ToString()) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true); } else if (_productOrder.Order_Status == eOrderStatus.Packed.ToString() && (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() || ddlSorderStatus.Text == eOrderStatus.Approved.ToString() || ddlSorderStatus.Text == eOrderStatus.Packed.ToString())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true); } else if (_productOrder.Order_Status == eOrderStatus.Shipped.ToString() && (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() || ddlSorderStatus.Text == eOrderStatus.Approved.ToString())) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true); } else if (ddlSorderStatus.Text == eOrderStatus.Placed.ToString() || ddlSorderStatus.Text == eOrderStatus.Approved.ToString() || ddlSorderStatus.Text == eOrderStatus.Packed.ToString() || ddlSorderStatus.Text == eOrderStatus.Shipped.ToString()) { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is lower then current.', { title: 'Failed!! ' });", true); } else { _productOrder.Order_Status = ddlSorderStatus.Text; ctx.Entry(_productOrder).State = EntityState.Modified; ctx.SaveChanges(); var adminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()]); Administrators _adm = ctx.Administrator.Where(m => m.Administrators_Id == adminId).FirstOrDefault(); OrderHistory _orderCancel = new OrderHistory(); _orderCancel.Order_Id = Convert.ToInt32(hdnOrderId.Value); _orderCancel.OrderHistory_Description = txtOrderDescription.Text; _orderCancel.OrderHistory_Status = ddlSorderStatus.Text; _orderCancel.OrderHistory_CreatedDate = DateTime.Now; _orderCancel.OrderHistory_UpdatedDate = DateTime.Now; _orderCancel.Administrators_Id = _adm.Administrators_Id; _orderCancel.Store_Id = _adm.Store_Id; ctx.OrderHistories.Add(_orderCancel); ctx.SaveChanges(); if (pnlDeleveryTeam.Visible == true) { OrderDelivery OrderDelivery = new OrderDelivery() { Order_Id = _productOrder.Order_Id, Administrators_Id = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString()), TeamId = Convert.ToInt32(ddlDelieveryTeam.SelectedValue.ToString()), Comment = txtOrderDescription.Text, Status = eOrderDeliveryStatus.InTransist.ToString(), Store_Id = _productOrder.Store_Id, Customer_Id = _productOrder.Customer_Id, DateCreated = DateTime.Now, DateUpdated = DateTime.Now }; ctx.OrderDelivery.Add(OrderDelivery); ctx.SaveChanges(); } Customers _cust = ctx.Customer.ToList().Where(m => m.Customer_Id == Convert.ToInt32(_productOrder.Customer_Id)).FirstOrDefault(); string productUrl = "http://rachnateracotta.com/product/index?id=" + _productOrder.Product_Id; _res = _res + "<tr style='border: 1px solid black;'><td style='border: 1px solid black;'><img src='" + _productOrder.Product_Banner + "' width='100' height='100'/></td>" + "<td style='border: 1px solid black;'><a href='" + productUrl + "'>" + _productOrder.Product_Title + "</a></td><td style='border: 1px solid black;'> Total Quantity :" + _productOrder.Order_Qty + " </td><td style='border: 1px solid black;'> " + _productOrder.Order_Price + " </td></tr>"; if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"])) { string host = string.Empty; host = "<table style='width:100%'>" + _res + "</ table >"; string body = MailHelper.CustomerOrderProcessed(host, (_cust.Customers_FullName), txtOrderDescription.Text); MailHelper.SendEmail(_cust.Customers_EmailId, "Success!!! " + txtOrderDescription.Text + " Rachna Teracotta Estore.", body, "Rachna Teracotta Order" + txtOrderDescription.Text); } Response.Redirect("/adminvendor/salesmanagement/vorderdetail.aspx?orderId=" + hdnOrderId.Value + "&requesttype=view-order-detail.html"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is same as current.', { title: 'Failed!! ' });", true); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "Order", "new Messi('update failed because, order status is not valid.', { title: 'Failed!! ' });", true); } } }