public ActionResult Edit(promotion promotion, HttpPostedFileBase[] files, String[] usertypes, string value) { if (ModelState.IsValid) { if (files != null) { for (int i = 0; i < files.Length; i++) { if (files[i] != null) { string path = ""; path = Path.Combine(Server.MapPath("/Content/ProductImage"), Path.GetFileName(files[i].FileName)); var picId = db.artlinks.OrderByDescending(x => x.LINENO).FirstOrDefault(); files[i].SaveAs(path); } } } promotion.TYPEUSERS = String.Join(",", usertypes); promotion.LASTCHANGE = DateTime.Now; db.Entry(promotion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(promotion)); }
public ActionResult EditUser(user model) { var user = db.users.Find(model.Id); db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit(settingtype settingtype) { if (ModelState.IsValid) { db.Entry(settingtype).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(settingtype)); }
public ActionResult Create(AllModel model, HttpPostedFileBase[] inputfile) { if (model.tblStoreArray != null) { var storeF = new store { CodeLanguage = model.tblStoreArray[0].CodeLanguage.ToLower(), Name = model.tblStoreArray[0].Name, Location = model.tblStoreArray[0].Location, Description = model.tblStoreArray[0].Description }; db.stores.Add(storeF); db.SaveChanges(); var updateItem = db.stores.Find(storeF.Id); updateItem.IdCurrentItem = storeF.Id; db.Entry(updateItem).State = EntityState.Modified; db.SaveChanges(); foreach (var item in model.tblStoreArray.Skip(1).ToList()) { var tblStore = new store { CodeLanguage = item.CodeLanguage.ToLower(), IdCurrentItem = storeF.IdCurrentItem, Name = item.Name, Location = item.Location, Description = item.Description, }; db.stores.Add(tblStore); } if (inputfile != null) { for (int i = 0; i < inputfile.Length; i++) { if (inputfile[i] != null) { string path = ""; path = Path.Combine(Server.MapPath("/Content/ProductImage"), Path.GetFileName(inputfile[i].FileName)); inputfile[i].SaveAs(path); updateItem.UrlImage = "/Content/ProductImage/" + inputfile[i].FileName; } } } db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult EmailFogotPass(user model) { var messenge = 0; var tblUser = db.users.Find(model.Id); if (tblUser != null) { tblUser.password = model.password; db.Entry(tblUser).State = EntityState.Modified; db.SaveChanges(); messenge = 1; } ViewBag.Notification = messenge; return(View(tblUser)); }
public ActionResult Edit(shippingfee shippingfee, HttpPostedFileBase[] files) { if (ModelState.IsValid) { db.Entry(shippingfee).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(shippingfee)); }
public ActionResult Edit([Bind(Include = "Id,Name,Images,Code,Status")] slider slider) { if (ModelState.IsValid) { db.Entry(slider).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(slider)); }
public ActionResult Edit(category category) { if (ModelState.IsValid) { category.LASTCHANGE = DateTime.Now; db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Create(AllModel model, HttpPostedFileBase[] files) { if (ModelState.IsValid) { var checkStock = db.stocks.FirstOrDefault(x => x.STOCKNO == model.tblStock.STOCKNO && x.ARTNO == model.tblStock.ARTNO); if (checkStock != null) { var tblStock = db.stocks.Find(checkStock.LINENO); tblStock.VOLUME = checkStock.VOLUME + model.tblStock.VOLUME; tblStock.SIZENO = model.tblStock.SIZENO; db.Entry(tblStock).State = EntityState.Modified; } else { db.stocks.Add(model.tblStock); db.SaveChanges(); } return(RedirectToAction("Index")); } return(View(model.tblStock)); }
public ActionResult Create(AllModel model, HttpPostedFileBase[] inputfile) { if (model.tblStockCodArray != null) { var stoclF = new stockcod { CodeLanguage = model.tblStockCodArray[0].CodeLanguage.ToLower(), STOCKNAME = model.tblStockCodArray[0].STOCKNAME, STOCKCODE = model.tblStockCodArray[0].STOCKCODE, CREATED = DateTime.Now, LASTCHANGE = DateTime.Now }; db.stockcods.Add(stoclF); db.SaveChanges(); var updateItem = db.stockcods.Find(stoclF.STOCKNO); updateItem.IdCurrentItem = stoclF.STOCKNO; db.Entry(updateItem).State = EntityState.Modified; db.SaveChanges(); foreach (var item in model.tblStockCodArray.Skip(1).ToList()) { var tblStore = new stockcod { CodeLanguage = item.CodeLanguage.ToLower(), IdCurrentItem = stoclF.IdCurrentItem, STOCKNAME = item.STOCKNAME, STOCKCODE = item.STOCKCODE, CREATED = stoclF.CREATED, LASTCHANGE = stoclF.LASTCHANGE }; db.stockcods.Add(tblStore); } db.SaveChanges(); } return(RedirectToAction("Index")); }
public ActionResult GoogleTag(seo model) { if (model.id != 0) { var se = db.seos.Find(model.id); se.googleanalys = model.googleanalys; se.description = model.description; se.metatag = model.metatag; se.type = model.type; se.page = model.page; se.link = model.link; se.keyword = model.keyword; se.title = model.title; db.Entry(se).State = EntityState.Modified; db.SaveChanges(); } else { db.seos.Add(model); db.SaveChanges(); } return(View(model)); }
public ActionResult Edit(country country, HttpPostedFileBase[] files) { if (ModelState.IsValid) { if (files != null) { for (int i = 0; i < files.Length; i++) { if (files[i] != null) { string path = ""; path = Path.Combine(Server.MapPath("/Content/ProductImage"), Path.GetFileName(files[i].FileName)); var picId = db.artlinks.OrderByDescending(x => x.LINENO).FirstOrDefault(); files[i].SaveAs(path); country.urlimage = "/Content/ProductImage/" + files[i].FileName; } } } db.Entry(country).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(country)); }
public ActionResult Create(order order, string[] totalProduct) { try { order.submitDate = DateTime.Now; db.orders.Add(order); db.SaveChanges(); if (totalProduct != null) { var listItem = totalProduct.ToList().Distinct().ToList(); foreach (var item in listItem) { var itemId = int.Parse(item.Split('_')[0]); var tblItem = db.items.FirstOrDefault(x => x.ARTNO == itemId); var tblOrderDetail = db.orderdetails.FirstOrDefault(x => x.itemId == itemId && x.ocid == order.ocid); if (tblOrderDetail == null) { var tblOrder = new orderdetail { ocid = order.ocid, itemId = itemId, ocdetailqty = int.Parse(item.Split('_')[1]), ocdetailname = tblItem != null ? tblItem.ARTNAME : "" }; db.orderdetails.Add(tblOrder); } else { tblOrderDetail.ocdetailqty = int.Parse(item.Split('_')[1]); db.Entry(tblOrderDetail).State = EntityState.Modified; } } db.SaveChanges(); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } return(RedirectToAction("Index")); }
public ActionResult Edit(AllModel model) { //var tem = db.vocabularies.Find(vocabulary.id); if (model.tblVocabularyArray != null) { foreach (var item in model.tblVocabularyArray) { var tem = db.vocabularies.Find(item.id); tem.name = item.name; tem.description = item.description; tem.language = item.language; tem.code = item.code; db.Entry(tem).State = EntityState.Modified; } } db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create(AllModel model, HttpPostedFileBase inputfile) { // if (ModelState.IsValid) // { try { //save file if (model.tblFileArray != null && inputfile.ContentLength > 0) { string path = ""; try { path = Path.Combine(Server.MapPath("/UploadFile"), Path.GetFileName(inputfile.FileName)); inputfile.SaveAs(path); //save other infomation var matagroup = new file(); matagroup.FileName = inputfile.FileName; matagroup.Status = "Active"; matagroup.FileAddress = path; matagroup.Title = model.tblFileArray[0].Title; matagroup.Description = model.tblFileArray[0].Description; matagroup.CodeLanguage = model.tblFileArray[0].CodeLanguage; matagroup.UploadDate = DateTime.Now; matagroup.UploadBy = User.Identity.Name; matagroup.Kind = inputfile.ContentType; db.files.Add(matagroup); db.SaveChanges(); var updatematagroup = db.files.Find(matagroup.Id); updatematagroup.IdCurrentItem = matagroup.Id; db.Entry(updatematagroup).State = EntityState.Modified; db.SaveChanges(); foreach (var item in model.tblFileArray.Skip(1).ToList()) { var matagroupL = new file(); matagroupL.FileName = item.FileName; matagroupL.Status = "Active"; matagroupL.FileAddress = path; matagroupL.Title = item.Title; matagroupL.Description = item.Description; matagroupL.CodeLanguage = item.CodeLanguage; matagroupL.UploadDate = DateTime.Now; matagroupL.UploadBy = User.Identity.Name; matagroupL.Kind = inputfile.ContentType; db.files.Add(matagroupL); } db.SaveChanges(); ViewBag.Message = "File uploaded successfully"; //save other infomation } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } } else { ViewBag.Message = "You have not specified a file."; } } catch (Exception ex) { } return(RedirectToAction("Index")); }
public ActionResult Create(AllModel model, HttpPostedFileBase[] inputfile) { if (model.tblMasterMetaGroupArray != null) { var matagroup = new metagrup(); matagroup.PARENTNO = 0; matagroup.IsActive = model.tblMasterMetaGroup.IsActive; matagroup.CREATED = DateTime.Now; matagroup.METAGROUPNAME = model.tblMasterMetaGroupArray[0].METAGROUPNAME; matagroup.METAGROUPCODE = model.tblMasterMetaGroupArray[0].METAGROUPCODE; matagroup.CodeLanguage = model.tblMasterMetaGroupArray[0].CodeLanguage; db.metagrups.Add(matagroup); db.SaveChanges(); var updatematagroup = db.metagrups.Find(matagroup.METAGROUPNO); updatematagroup.IdCurrentItem = matagroup.METAGROUPNO; db.Entry(updatematagroup).State = EntityState.Modified; db.SaveChanges(); foreach (var item in model.tblMasterMetaGroupArray.Skip(1).ToList()) { item.PARENTNO = 0; item.IsActive = model.tblMasterMetaGroup.IsActive; item.CREATED = DateTime.Now; item.IdCurrentItem = updatematagroup.IdCurrentItem; db.metagrups.Add(item); } db.SaveChanges(); if (inputfile != null) { for (int i = 0; i < inputfile.Length; i++) { if (inputfile[i] != null) { var fname = matagroup.IdCurrentItem + "." + inputfile[i].FileName.Split('.').Last(); string path = Server.MapPath("~/Content/MetagroupImage"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path + "/", fname); inputfile[i].SaveAs(path); } } } } return(RedirectToAction("Index")); }
public ActionResult Create(AllModel model, HttpPostedFileBase[] inputfile) { try { if (model.tblProductArray != null) { var artCode = Guid.NewGuid().ToString().Substring(0, 8).ToUpper(); var itemF = new item(); itemF.ARTTYPE = 1; itemF.CREATED = DateTime.Now; itemF.LASTCHANGE = DateTime.Now; itemF.ARTCODE = artCode; itemF.ARTNAME = model.tblProductArray[0].ARTNAME; itemF.INFO = model.tblProductArray[0].INFO; itemF.CodeLanguage = model.tblProductArray[0].CodeLanguage.ToLower(); itemF.GROUPNO = model.tblitem.GROUPNO; itemF.IsBestSeller = model.tblitem.IsBestSeller; itemF.EXPORTABLE = model.tblitem.EXPORTABLE; itemF.SPECIALOFFER = model.tblitem.SPECIALOFFER; itemF.STOCKITEM = model.tblitem.STOCKITEM; itemF.AUTHORIZABLE = model.tblitem.AUTHORIZABLE; itemF.RESTRICTED = model.tblitem.RESTRICTED; itemF.NOTPOST = model.tblitem.NOTPOST; itemF.NOTADDPOSTAGEFEE = model.tblitem.NOTADDPOSTAGEFEE; itemF.WIDTH = model.tblitem.WIDTH; itemF.WEIGHT = model.tblitem.WEIGHT; itemF.LEN = model.tblitem.LEN; itemF.HEIGHT = model.tblitem.HEIGHT; itemF.WEBPRICE = model.tblitem.WEBPRICE; db.items.Add(itemF); db.SaveChanges(); var updateItem = db.items.Find(itemF.ARTNO); updateItem.IdCurrentItem = itemF.ARTNO; db.Entry(updateItem).State = EntityState.Modified; db.SaveChanges(); foreach (var item in model.tblProductArray.Skip(1).ToList()) { var tblItem = new item(); tblItem.ARTTYPE = 1; tblItem.CREATED = DateTime.Now; tblItem.LASTCHANGE = DateTime.Now; tblItem.ARTCODE = itemF.ARTCODE; tblItem.ARTNAME = item.ARTNAME; tblItem.INFO = item.INFO; tblItem.CodeLanguage = item.CodeLanguage.ToLower(); tblItem.GROUPNO = model.tblitem.GROUPNO; tblItem.IsBestSeller = model.tblitem.IsBestSeller; tblItem.EXPORTABLE = model.tblitem.EXPORTABLE; tblItem.SPECIALOFFER = model.tblitem.SPECIALOFFER; tblItem.STOCKITEM = model.tblitem.STOCKITEM; tblItem.AUTHORIZABLE = model.tblitem.AUTHORIZABLE; tblItem.RESTRICTED = model.tblitem.RESTRICTED; tblItem.NOTPOST = model.tblitem.NOTPOST; tblItem.NOTADDPOSTAGEFEE = model.tblitem.NOTADDPOSTAGEFEE; tblItem.WIDTH = model.tblitem.WIDTH; tblItem.WEIGHT = model.tblitem.WEIGHT; tblItem.LEN = model.tblitem.LEN; tblItem.HEIGHT = model.tblitem.HEIGHT; tblItem.IdCurrentItem = itemF.IdCurrentItem; tblItem.WEBPRICE = model.tblitem.WEBPRICE; db.items.Add(tblItem); } db.SaveChanges(); if (inputfile != null) { for (int i = 0; i < inputfile.Length; i++) { if (inputfile[i] != null) { string path = ""; path = Path.Combine(Server.MapPath("/Content/ProductImage"), Path.GetFileName(inputfile[i].FileName)); inputfile[i].SaveAs(path); var i1 = itemF.IdCurrentItem > 0 ? itemF.IdCurrentItem:0; if (i1 != null) { var tblPic = new artlink { ARTNO = (int)i1, LASTCHANGE = DateTime.Now, CREATED = DateTime.Now, LINK = inputfile[i].FileName }; db.artlinks.Add(tblPic); } db.SaveChanges(); } } } } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } return(RedirectToAction("Index")); }
public ActionResult Create(order order, int?checkBilldingShipping) { if (ModelState.IsValid) { if (Session["ShoppingCart"] == null) { return(RedirectToAction("UpdateCart", "Home")); } else { try { var oldPriceOrder = 0.0; if (order.ocid > 0) { var _order = db.orders.Where(t => t.ocid == order.ocid).FirstOrDefault(); oldPriceOrder = _order.paid_amount.HasValue ? _order.paid_amount.Value : 0; db.Entry(_order).State = EntityState.Detached; db.SaveChanges(); } order.d_companyname = string.IsNullOrEmpty(order.d_companyname) ? order.companyname : order.d_companyname; order.d_fname = string.IsNullOrEmpty(order.d_fname) ? order.fname : order.d_fname; order.d_lname = string.IsNullOrEmpty(order.d_lname) ? order.lname : order.d_lname; order.d_email = string.IsNullOrEmpty(order.d_email) ? order.email : order.d_email; order.d_phone = string.IsNullOrEmpty(order.d_phone) ? order.phone : order.d_phone; order.d_addr1 = string.IsNullOrEmpty(order.d_addr1) ? order.addr1 : order.d_addr1; if (checkBilldingShipping.HasValue && checkBilldingShipping.Value == 1) { order.b_companyname = string.IsNullOrEmpty(order.d_companyname) ? order.companyname : order.d_companyname; order.b_fname = string.IsNullOrEmpty(order.d_fname) ? order.fname : order.d_fname; order.b_lname = string.IsNullOrEmpty(order.d_lname) ? order.lname : order.d_lname; order.b_email = string.IsNullOrEmpty(order.d_email) ? order.email : order.d_email; order.b_phone = string.IsNullOrEmpty(order.d_phone) ? order.phone : order.d_phone; order.b_addr1 = string.IsNullOrEmpty(order.d_addr1) ? order.addr1 : order.d_addr1; } order.status = "2"; if (order.payoption == "PayPal") { order.paid_status = 2; } if (order.payoption == "COD") { order.paid_status = 1; } ShoppingCart Cart = new ShoppingCart(); Cart = (ShoppingCart)Session["ShoppingCart"]; order.paid_amount = Cart.CartTotal + Cart.taxTotal; String randomKey = Guid.NewGuid().ToString(); if (order.ocid == 0) { order.paid_key = randomKey; db.orders.Add(order); db.SaveChanges(); } else { db.Entry(order).State = EntityState.Modified; db.SaveChanges(); } Cart.paid_key = order.paid_key; WebApplication1.Models.AllLoggedUserInfo userFullInfo = (WebApplication1.Models.AllLoggedUserInfo)Session["LoggedAccount"]; if (userFullInfo != null) { var user = db.users.Find(userFullInfo.user.Id); user.paidorder = (user.paidorder ?? 0) + (decimal)Cart.CartTotal + (decimal)(order.feeshipping ?? 0) - (decimal)oldPriceOrder; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); } double cartAmount = 0; string currencyName = "USD"; ordersetting ordersetting = db.ordersettings.Where(t => t.status == 1).FirstOrDefault(); if (ordersetting != null) { currencyName = ordersetting.name; } var itemList = new ItemList(); var items = new List <Item>(); String paypalURL = ""; var paypayconfig = new PayPalConfiguration(); var apiContext = paypayconfig.GetAPIContext(); var _orderdetails = db.orderdetails.Where(t => t.ocid == order.ocid).ToList(); var listItems = _orderdetails.Select(t => t.ocdetailcode); var _items = db.items.Where(t => listItems.Contains(t.ARTCODE)).ToList(); foreach (var item in _orderdetails) { if (item.stockId.HasValue && item.stockId.Value > 0) { var _item = _items.FirstOrDefault(t => t.ARTCODE == item.ocdetailcode); if (_item != null) { var _stock = db.stocks.Where(t => t.ARTNO == item.itemId && t.STOCKNO == item.stockId).FirstOrDefault(); _stock.VOLUME += item.ocdetailqty.Value; db.Entry(_stock).State = EntityState.Modified; } } } db.orderdetails.RemoveRange(_orderdetails); var _listItems = Cart.cartItem.Select(t => t.Code); var __items = db.items.Where(t => _listItems.Contains(t.ARTCODE)).ToList(); foreach (var item in Cart.cartItem) { orderdetail od = new orderdetail(); od.ocid = order.ocid; od.ocdetailcode = item.Code; od.ocdetailname = item.Name; od.ocdetailprice = item.Price; od.ocdetailqty = item.Qty; od.ocdetailgst = item.Tax / item.Qty; od.stockId = item.StockId; if (item.StockId > 0) { var _item = __items.FirstOrDefault(t => t.ARTCODE == od.ocdetailcode); if (_item != null) { var _stock = db.stocks.Where(t => t.ARTNO == _item.ARTNO && t.STOCKNO == item.StockId).FirstOrDefault(); _stock.VOLUME -= item.Qty; db.Entry(_stock).State = EntityState.Modified; od.itemId = _item.ARTNO; } } db.orderdetails.Add(od); var Item = new Item(); Item.name = item.Code + " - " + item.Name; Item.currency = currencyName; Item.price = (item.Price + (item.Tax / item.Qty)) + ""; Item.quantity = item.Qty + ""; items.Add(Item); } if (order.feeshipping.HasValue && order.feeshipping.Value > 0) { var Item = new Item(); Item.name = "Fee Shipping"; Item.currency = currencyName; Item.price = order.feeshipping + ""; Item.quantity = "1"; items.Add(Item); } if (Cart.promotion != null) { if (Cart.promotion.TYPENO == 0) { var Item = new Item(); Item.name = "Discount Promotion"; Item.currency = currencyName; Item.price = "-" + Cart.PromotionTotal + ""; Item.quantity = "1"; items.Add(Item); } } cartAmount = Cart.CartTotal + Cart.taxTotal + order.feeshipping ?? 0; cartAmount = Math.Round(cartAmount, 2); itemList.items = items; db.SaveChanges(); if (order.payoption == "PayPal") { var payer = new Payer() { payment_method = "paypal" }; var redirUrls = new RedirectUrls() { cancel_url = UrlHelper.Root + "Checkout/PayPalCancel?" + UrlHelper.ToQueryString(new { paid_key = order.paid_key }), return_url = UrlHelper.Root + "Checkout/PayPalSuccess?" + UrlHelper.ToQueryString(new { paid_key = order.paid_key }) }; var paypalAmount = new Amount() { currency = currencyName, total = cartAmount.ToString() }; var transactionList = new List <PayPal.Api.Transaction>(); PayPal.Api.Transaction transaction = new PayPal.Api.Transaction(); transaction.amount = paypalAmount; transaction.item_list = itemList; transactionList.Add(transaction); var payment = new Payment() { intent = "Sale", payer = payer, transactions = transactionList, redirect_urls = redirUrls }; try { var createdPayment = payment.Create(apiContext); var links = createdPayment.links.GetEnumerator(); while (links.MoveNext()) { var link = links.Current; if (link.rel.ToLower().Trim().Equals("approval_url")) { paypalURL = link.href; } } return(Redirect(paypalURL)); } catch (PaymentsException ex) { paypalURL = "ERROR: " + ex.Response; } } else { SendTemplateEmail(order.d_email, order.d_email, "", "Order Success #" + order.ocid + "" + DateTime.Now.Day, 1, Cart, order); SendTemplateEmail(order.d_email, order.d_email, "", "Order Success #" + order.ocid + "" + DateTime.Now.Day, 3, Cart, order); return(RedirectToAction("Thankyou")); } } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } } } } return(RedirectToAction("Create")); }