public ActionResult Index() { long cusid = 0; if (Request.Cookies.AllKeys.Contains("customerId")) { cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid).FirstOrDefault(); if (customerinfo.Mobile == "" || customerinfo.Mobile == null || customerinfo.Address == "" || customerinfo.Address == null) { return(RedirectToAction("Index", "fCArea")); } List <CustomerProduct> CustomerProduct = db.CustomerProduct.Where(p => p.CustomerId == cusid && p.IdState == 1 && p.StateDelete == false).ToList(); if (CustomerProduct.Count() > 0 && CustomerProduct != null) { var result = getinfopaymentpage(); return(View(result)); } else { return(RedirectToAction("Index", "fproducts")); } } else { return(RedirectToAction("Index", "fLR")); } }
public async Task <ActionResult> NotConfirm(long id) { string UserIdcookie = ""; UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); if (usr.Where(p => p.IdRole == 6).Any()) { Exitorder exo = db.Exitorder.Find(id); RecordEntryExitOrder ree = db.RecordEntryExitOrder.Where(p => p.IdExitOrder == exo.Id).FirstOrDefault(); Record_the_entry re = db.Record_the_entry.Where(p => p.Id == ree.IdRecordEntry).FirstOrDefault(); re.ExitState = false; db.RecordEntryExitOrder.Remove(ree); db.Exitorder.Remove(exo); await db.SaveChangesAsync(); return(Json("Ok", JsonRequestBehavior.AllowGet)); } else { return(new HttpStatusCodeResult(513)); } }
public ActionResult Index() { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { return(View()); } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult SIndex(vmcopreserv vmr) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { var result = SgetCopReserve(vmr); ViewBag.AllPage = 1; ViewBag.PageNumber = 1; return(View(result)); } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public async Task <ActionResult> checkdiscountcod(string dicode) { long cusid = 0; if (Request.Cookies.AllKeys.Contains("customerId")) { cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid).FirstOrDefault(); } else { return(new HttpStatusCodeResult(508)); } discountcode _discountcode = db.discountcode.Where(p => p.dicountcode == dicode).FirstOrDefault(); if (_discountcode == null) { return(new HttpStatusCodeResult(506)); } DateTime dateend = _discountcode.dateende; DateTime datenow = DateTime.Now; if (datenow > dateend) { return(new HttpStatusCodeResult(507)); } if (_discountcode.numberofuseg == 0 || _discountcode.numberofuseg == null) { _discountcode.numberofuseg = 1; _discountcode.customerid = cusid; await db.SaveChangesAsync(); List <CustomerProduct> customerProducts = db.CustomerProduct.Where(p => p.CustomerId == cusid && p.IdState == 1).ToList(); foreach (var item in customerProducts) { factor factor = db.factor.Where(p => p.factorcode == item.factorcod).FirstOrDefault(); factor.discountcode = _discountcode.dicountcode; factor.discountpercent = _discountcode.discountpersent; } await db.SaveChangesAsync(); } else if (_discountcode.numberofuseg >= 1) { return(new HttpStatusCodeResult(509)); } return(Json(_discountcode.discountpersent, JsonRequestBehavior.AllowGet)); }
public ActionResult Index(int?PageNumber) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { if (usr.Where(p => p.IdRole == 2).Any()) { if (PageNumber == null) { var result = GetExitOrder(1); TempData["data"] = result; ViewBag.PageNumber = 1; ViewBag.AllPage = getTotalList(); return(View(result)); } else { var result = GetExitOrder((int)PageNumber); TempData["data"] = result; ViewBag.PageNumber = (int)PageNumber; ViewBag.AllPage = getTotalList(); return(View(result)); } } else { return(RedirectToAction("AccessDenied", "Error")); } } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult SIndex(listRecordEntryExitOrder vmr) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { if (usr.Where(p => p.IdRole == 2).Any()) { var result = SGetExitOrder(vmr); TempData["data"] = result; ViewBag.PageNumber = 1; ViewBag.AllPage = 1; ViewBag.minename = vmr.minename; ViewBag.copname = vmr.copname; ViewBag.Weight = vmr.Weight; ViewBag.StoreName = vmr.StoreName; ViewBag.Dimensions = vmr.Dimensions; ViewBag.CopCode = vmr.CopCode; ViewBag.Transfernumber = vmr.Transfernumber; ViewBag.Uploaddate = vmr.Uploaddate; return(View(result)); } else { return(RedirectToAction("AccessDenied", "Error")); } } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult LoadEditCopsBooking(long id) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { List <RecordEntryCopsBooking> RecordEntryCopsBooking = db.RecordEntryCopsBooking.Where(p => p.IdCopsBooking == id).ToList(); var listrecordentry = db.Record_the_entry.Where(p => p.StateDelete == 0).ToList() .Select(p => new vmListRecordEntry { Id = p.Id, minename = p.mine.Name, copname = p.Cops.Name, Dimensions = p.length + "*" + p.width + "*" + p.Height, Weight = p.Weight, CopsCod = p.CopsCod, Transfernumber = p.Transfernumber, }).ToList(); List <Store> ListStore = db.Store.Where(p => p.StateDelete == 0).ToList(); vmEditCopReserv _vmEditCopReserv = new vmEditCopReserv(); _vmEditCopReserv.RecordEntryCopsBooking = RecordEntryCopsBooking; _vmEditCopReserv.ListRecordEntry = listrecordentry; _vmEditCopReserv.ListStore = ListStore; return(View(_vmEditCopReserv)); } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public async Task <ActionResult> changecuspass(Customer _mcustomer) { long cusid = 0; cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer _edmcustomer = db.Customer.Find(cusid); var pass = CreatHash.HashPass(_mcustomer.Password); _edmcustomer.Password = pass; await db.SaveChangesAsync(); return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult Index(int?PageNumber) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { if (PageNumber == null) { var result = getCopReserve(1); ViewBag.AllPage = (db.CopsBooking.Where(p => p.StateDelete == 0).Count() / 10) + 1; ViewBag.PageNumber = 1; return(View(result)); } else { var result = getCopReserve((int)PageNumber); ViewBag.AllPage = (db.CopsBooking.Where(p => p.StateDelete == 0).Count() / 10) + 1; ViewBag.PageNumber = (int)PageNumber; return(View(result)); } } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public ActionResult SIndex(listRecordEntryExitOrder vmr) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { var result = SGetExitOrder(vmr); ViewBag.PageNumber = 1; ViewBag.AllPage = 1; ViewBag.customerFullName = vmr.CustomerFullName; ViewBag.StoreName = vmr.StoreName; ViewBag.RecordEntryExitOrderCount = vmr.RecordEntryExitOrderCount; ViewBag.stateName = vmr.stateName; ViewBag.Uploaddate = vmr.Uploaddate; return(View(result)); } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public object getcustomerinfo() { long cusid = 0; cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid && p.Statedelete == false).FirstOrDefault(); List <CustomerProduct> Cp = db.CustomerProduct.Where(p => p.CustomerId == cusid && p.StateDelete == false).ToList(); List <CustomerProjectTicket> cpt = db.CustomerProjectTicket.Where(p => p.IdCustomer == cusid).ToList(); vmCArea _vmCArea = new vmCArea(); _vmCArea.Customer = customerinfo; _vmCArea.CustomerProducts = Cp; _vmCArea.CustomerProjectTickets = cpt; return(_vmCArea); }
public ActionResult Index() { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { if (usr.Where(p => p.IdRole == 5).Any()) { // var result = getRecordEntry(); return(View()); } else { return(RedirectToAction("AccessDenied", "Error")); } } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public async Task <ActionResult> deletecustomerproduct(CustomerProduct _deletecustomerproduct) { long cusid = 0; if (Request.Cookies.AllKeys.Contains("customerId")) { cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); CustomerProduct customerProduct = db.CustomerProduct.Where(p => p.CustomerId == cusid && p.Id == _deletecustomerproduct.Id).FirstOrDefault(); customerProduct.StateDelete = true; customerProduct.DateDelete = DateTime.Now; customerProduct.ResonOfCancelletion = _deletecustomerproduct.ResonOfCancelletion; await db.SaveChangesAsync(); return(Json("Ok", JsonRequestBehavior.AllowGet)); } else { return(new HttpStatusCodeResult(506)); } }
public ActionResult ediddata(long id) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { Record_the_entry re = db.Record_the_entry.Find(id); List <mine> listmine = db.mine.Where(p => p.StateDelete == 0).ToList(); List <Cops> listCops = db.Cops.Where(p => p.StateDelete == 0).ToList(); List <Store> listStore = db.Store.Where(p => p.StateDelete == 0).ToList(); vmEditRecordEntry _vmEditRecordEntry = new vmEditRecordEntry(); _vmEditRecordEntry.re = re; _vmEditRecordEntry.listmine = listmine; _vmEditRecordEntry.listCops = listCops; _vmEditRecordEntry.listStore = listStore; return(View(_vmEditRecordEntry)); } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public object getinfopaymentpage() { long cusid = 0; cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid).FirstOrDefault(); List <CustomerProduct> CustomerProduct = db.CustomerProduct.Where(p => p.CustomerId == cusid && p.IdState == 1 && p.StateDelete == false).ToList(); long?amount = 0; long sendcost = 0; var sendcost1 = db.sendcost.FirstOrDefault(); if (sendcost1 == null) { sendcost = 0; } else { sendcost = sendcost1.SendCost1; } foreach (var item in CustomerProduct) { amount += item.TotalPrice; } amount = amount + sendcost; vmPayment _vmPayment = new vmPayment(); _vmPayment.Amount = amount; _vmPayment.Customerinfo = customerinfo; _vmPayment.sendcoust = sendcost; _vmPayment.CustomerProduct = CustomerProduct; return(_vmPayment); }
public async Task <ActionResult> Checking(long id) { string UserIdcookie = ""; UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); if (usr.Where(p => p.IdRole == 6).Any()) { Exitorder exo = db.Exitorder.Find(id); exo.IdState = 3; await db.SaveChangesAsync(); return(Json("Ok", JsonRequestBehavior.AllowGet)); } else { return(new HttpStatusCodeResult(513)); } }
private object SGetExitOrder(listRecordEntryExitOrder vmr) { string UserIdcookie = ""; UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); UserStoreRole UserStoreRole = db.UserStoreRole.Where(p => p.IdUser == admin.Id).FirstOrDefault(); if (usr.Where(p => p.IdRole == 8).Any()) { var lists = db.Exitorder.Where(p => p.StateDelete == 0 && p.IdState != 4 && p.IdState != 2) .ToList() .Select(p => new listRecordEntryExitOrder { Id = p.Id, CustomerFullName = p.CustomerFullName, Uploaddate = clsPersianDate.MiladiToShamsi(p.Uploaddate), StoreName = p.Store.Name, stateName = p.State.Name, RecordEntryExitOrderCount = p.RecordEntryExitOrder.Where(q => q.IdExitOrder == p.Id).Count() }).ToList(); if (vmr.Uploaddate != null) { lists = lists.Where(p => p.Uploaddate == vmr.Uploaddate).ToList(); } if (vmr.CustomerFullName != null) { lists = lists.Where(p => p.CustomerFullName.Contains(vmr.CustomerFullName)).ToList(); } if (vmr.StoreName != null) { lists = lists.Where(p => p.StoreName.Contains(vmr.StoreName)).ToList(); } if (vmr.RecordEntryExitOrderCount != 0) { lists = lists.Where(p => p.RecordEntryExitOrderCount == vmr.RecordEntryExitOrderCount).ToList(); } if (vmr.stateName != null) { lists = lists.Where(p => p.stateName.Contains(vmr.stateName)).ToList(); } vmReportBargirt _vmReportBargirt = new vmReportBargirt(); _vmReportBargirt.list = lists; return(_vmReportBargirt); } else { var lists = db.Exitorder.Where(p => p.StateDelete == 0 && p.IdStore == UserStoreRole.IdStore) .ToList() .Select(p => new listRecordEntryExitOrder { Id = p.Id, CustomerFullName = p.CustomerFullName, Uploaddate = clsPersianDate.MiladiToShamsi(p.Uploaddate), StoreName = p.Store.Name, stateName = p.State.Name, RecordEntryExitOrderCount = p.RecordEntryExitOrder.Where(q => q.IdExitOrder == p.Id).Count() }).ToList(); if (vmr.Uploaddate != "" || vmr.Uploaddate != null) { lists = lists.Where(p => p.Uploaddate == vmr.Uploaddate).ToList(); } if (vmr.CustomerFullName != null) { lists = lists.Where(p => p.CustomerFullName.Contains(vmr.CustomerFullName)).ToList(); } if (vmr.StoreName != null) { lists = lists.Where(p => p.StoreName.Contains(vmr.StoreName)).ToList(); } if (vmr.RecordEntryExitOrderCount != 0) { lists = lists.Where(p => p.RecordEntryExitOrderCount == vmr.RecordEntryExitOrderCount).ToList(); } if (vmr.stateName != null) { lists = lists.Where(p => p.stateName.Contains(vmr.stateName)).ToList(); } vmReportBargirt _vmReportBargirt = new vmReportBargirt(); _vmReportBargirt.list = lists; return(_vmReportBargirt); } }
private object GetExitOrder(int PageNumber) { if (PageNumber <= 0) { PageNumber = 1; } int PageSkip = (PageNumber - 1) * PageOffSet; string UserIdcookie = ""; UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); UserStoreRole UserStoreRole = db.UserStoreRole.Where(p => p.IdUser == admin.Id).FirstOrDefault(); if (usr.Where(p => p.IdRole == 8).Any()) { var lists = db.Exitorder.Where(p => p.StateDelete == 0 && p.IdState != 4 && p.IdState != 2) .ToList() .Select(p => new listRecordEntryExitOrder { Id = p.Id, CustomerFullName = p.CustomerFullName, Uploaddate = clsPersianDate.MiladiToShamsi(p.Uploaddate), StoreName = p.Store.Name, stateName = p.State.Name, RecordEntryExitOrderCount = p.RecordEntryExitOrder.Where(q => q.IdExitOrder == p.Id).Count() }).OrderBy(u => u.Id) .Skip(PageSkip) .Take(PageOffSet) .ToList(); vmReportBargirt _vmReportBargirt = new vmReportBargirt(); _vmReportBargirt.list = lists; _vmReportBargirt.AllPage = (db.Exitorder.Where(p => p.StateDelete == 0).Count() / 10) + 1; return(_vmReportBargirt); } else { var lists = db.Exitorder.Where(p => p.StateDelete == 0 && p.IdStore == UserStoreRole.IdStore) .ToList() .Select(p => new listRecordEntryExitOrder { Id = p.Id, CustomerFullName = p.CustomerFullName, Uploaddate = clsPersianDate.MiladiToShamsi(p.Uploaddate), StoreName = p.Store.Name, stateName = p.State.Name, RecordEntryExitOrderCount = p.RecordEntryExitOrder.Where(q => q.IdExitOrder == p.Id).Count() }).OrderBy(u => u.Id) .Skip(PageSkip) .Take(PageOffSet) .ToList(); vmReportBargirt _vmReportBargirt = new vmReportBargirt(); _vmReportBargirt.list = lists; _vmReportBargirt.AllPage = (db.Exitorder.Where(p => p.StateDelete == 0).Count() / 10) + 1; return(_vmReportBargirt); } }
public async Task <ActionResult> mngcustomer(Customer _mcustomer, HttpPostedFileBase _file1) { string fileImagename = ""; if (!Request.Cookies.AllKeys.Contains("customerId")) { var unqusername = db.Customer.Where(p => p.UserName == _mcustomer.UserName).Any(); var unquemail = db.Customer.Where(p => p.Email == _mcustomer.Email).Any(); if (unqusername == true || unquemail == true) { return(new HttpStatusCodeResult(503)); } var pass = CreatHash.HashPass(_mcustomer.Password); _mcustomer.Password = pass; _mcustomer.DateInsert = DateTime.Now; _mcustomer.Statedelete = false; if (Request.Files != null && Request.Files.Count != 0) { _file1 = Request.Files[0]; if (!_file1.ContentType.Contains("image/jpeg")) { return(new HttpStatusCodeResult(502)); } var number = new Random(); fileImagename = number.Next(1, 999999999).ToString() + _file1.FileName; var path = Path.Combine(Server.MapPath("~/Image/CustomerImage"), fileImagename); _file1.SaveAs(path); _mcustomer.userimage = fileImagename; } db.Customer.Add(_mcustomer); await db.SaveChangesAsync(); return(Json("Ok", JsonRequestBehavior.AllowGet)); } else { long cusid = 0; cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer _edmcustomer = db.Customer.Find(cusid); if (_mcustomer.Address == "" || _mcustomer.Address == null || _mcustomer.Mobile == "" || _mcustomer.Mobile == null || _mcustomer.Tel == "" || _mcustomer.Tel == null) { return(new HttpStatusCodeResult(505)); } bool uniquemail = db.Customer.Where(p => p.Email == _mcustomer.Email && p.Id != _edmcustomer.Id).Any(); bool uniquusername = db.Customer.Where(p => p.UserName == _mcustomer.UserName && p.Id != _edmcustomer.Id).Any(); if (uniquemail == true || uniquusername == true) { return(new HttpStatusCodeResult(503)); } _edmcustomer.Address = _mcustomer.Address; _edmcustomer.CompanyName = _mcustomer.CompanyName; _edmcustomer.DateUpdate = DateTime.Now; _edmcustomer.Email = _mcustomer.Email; _edmcustomer.FullName = _mcustomer.FullName; _edmcustomer.Mobile = _mcustomer.Mobile; _edmcustomer.Statedelete = false; _edmcustomer.Tel = _mcustomer.Tel; _edmcustomer.UserName = _mcustomer.UserName; if (Request.Files != null && Request.Files.Count != 0) { _file1 = Request.Files[0]; if (!_file1.ContentType.Contains("image/jpeg")) { return(new HttpStatusCodeResult(502)); } if (_edmcustomer.userimage != null && _edmcustomer.userimage != "") { var oldimg = Path.Combine(Server.MapPath("~/Image/CustomerImage"), _edmcustomer.userimage); if (System.IO.File.Exists(oldimg)) { System.IO.File.Delete(oldimg); } } var number = new Random(); fileImagename = number.Next(1, 999999999).ToString() + _file1.FileName; var path = Path.Combine(Server.MapPath("~/Image/CustomerImage"), fileImagename); _file1.SaveAs(path); _edmcustomer.userimage = fileImagename; } await db.SaveChangesAsync(); return(Json("Ok", JsonRequestBehavior.AllowGet)); } }
public async Task <ActionResult> registercustomerproduct(itemcart _prop, string discontcode, long?_toltalprice) { List <CustomerProduct> _customerproduct = new List <CustomerProduct>(); CustomerProduct _cp = null; long cusid = 0; if (Request.Cookies.AllKeys.Contains("customerId")) { cusid = Convert.ToInt64(CreatHash.Decrypt(Request.Cookies["customerId"].Value)); Customer customerinfo = db.Customer.Where(p => p.Id == cusid).FirstOrDefault(); if (customerinfo.Mobile == "" || customerinfo.Mobile == null || customerinfo.Address == "" || customerinfo.Address == null) { return(new HttpStatusCodeResult(504)); } } else { return(new HttpStatusCodeResult(501)); } Random r = new Random(); string factorcode = ""; for (int i = 0; i < _prop.ListProps.Count(); i++) { long prid = _prop.ListProps[i].Id; #region deletecookie HttpCookie cookie = Request.Cookies["ProductBasketCookie"]; cookie.Expires = DateTime.Now.AddDays(-11); Response.Cookies.Add(cookie); #endregion factorcode = _prop.ListProps[i].Id + r.Next(1, 999999999).ToString() + r.Next(1, 999999999).ToString(); long _prices; var _price = db.ProductProperty.Where(p => p.IdProduct == prid && p.IdProperty == 4).FirstOrDefault().Value; _prices = Convert.ToInt64(_price); _cp = new CustomerProduct(); _cp.Count = _prop.ListProps[i].Value; _cp.CustomerId = cusid; _cp.DateRequest = DateTime.Now; _cp.IdState = 1; _cp.ProductId = _prop.ListProps[i].Id; _cp.StateDelete = false; if (discontcode != null && discontcode != "") { var discountpercent = db.discountcode.Where(p => p.dicountcode == discontcode).FirstOrDefault().discountpersent; var totalprice = _prices - (_prices * discountpercent); _cp.TotalPrice = _prop.ListProps[i].Value * totalprice; _toltalprice = 0; _toltalprice += _cp.TotalPrice; } else { _cp.TotalPrice = _prop.ListProps[i].Value * _prices; _toltalprice = 0; _toltalprice += _cp.TotalPrice; } _cp.factorcod = factorcode; _customerproduct.Add(_cp); } factor _f = new factor(); _f.customerId = cusid; _f.dateinsert = DateTime.Now; _f.discountcode = discontcode; if (discontcode != null && discontcode != "") { _f.discountpercent = db.discountcode.Where(p => p.dicountcode == discontcode).FirstOrDefault().discountpersent; } else { _f.discountpercent = null; } _f.factorcode = factorcode; _f.prcount = _customerproduct.Count(); _f.statedelete = false; _f.totalprice = (long)_toltalprice; db.factor.Add(_f); db.CustomerProduct.AddRange(_customerproduct); await db.SaveChangesAsync(); return(Json("ok", JsonRequestBehavior.AllowGet)); }
public ActionResult EditUser(long?id) { try { string UserIdcookie = ""; if (Request.Cookies.AllKeys.Contains("UserId")) { UserIdcookie = Request.Cookies["UserId"].Value; string _Id = UserIdcookie; long Id = Convert.ToInt16(CreatHash.Decrypt(_Id)); Users admin = db.Users.FirstOrDefault(p => p.Id == Id); List <UserRole> usr = db.UserRole.Where(p => p.IdUser == admin.Id).ToList(); if (admin == null) { return(RedirectToAction("Index", "LogIn")); } else { if (id != null && id != 0) { if (usr.Where(p => p.IdRole == 4).Any()) { Users user = db.Users.Find(id); List <Role> listrole = db.Role.ToList(); List <UserRole> listuserrole = db.UserRole.ToList(); List <Store> listStore = db.Store.Where(p => p.StateDelete == 0).ToList(); List <UserStoreRole> listUserStoreRole = db.UserStoreRole.ToList(); vmlistuser _vmlistuser = new vmlistuser(); _vmlistuser.listrole = listrole; _vmlistuser.user = user; _vmlistuser.userrole = listuserrole; _vmlistuser.listStore = listStore; _vmlistuser.listUserStoreRole = listUserStoreRole; return(View(_vmlistuser)); } else { return(RedirectToAction("AccessDenied", "Error")); } } else { return(RedirectToAction("Index", "LogIn")); } } } else { return(RedirectToAction("Index", "LogIn")); } } catch (Exception ee) { return(RedirectToAction("Index", "LogIn")); } }
public object GetProductInfo(string id) { long idproduct = Convert.ToInt64(CreatHash.Decrypt(id)); Product _mainproduct = db.Product.Where(p => p.StateDelete == false && p.Id == idproduct).FirstOrDefault(); var _Pr = (from p in db.Product where p.StateDelete == false && p.Id == idproduct && p.Idparent != 0 select new ListProduct { ProductId = p.Id, Name = p.Name, ImageUrl = db.ProductImage.FirstOrDefault(x => x.IdProduct == p.Id && x.StateDelete == false).Url, Price = db.ProductProperty.FirstOrDefault(x => x.IdProduct == p.Id && x.IdProperty == 3).Value, CustomerPrice = db.ProductProperty.FirstOrDefault(x => x.IdProduct == p.Id && x.IdProperty == 4).Value, Percent = db.ProductProperty.FirstOrDefault(x => x.IdProduct == p.Id && x.IdProperty == 6).Value, Exist = p.StateExist, }).ToList(); var ImageProduct = db.ProductImage.Where(p => p.StateDelete == false && p.IdProduct == idproduct) .Select(p => new ImageProduct { ProductImageId = p.Id, Url = p.Url }).ToList(); var pGroups = (from pp in db.ProductProperty join pr in db.Property on pp.IdProperty equals pr.Id where pp.StateDelete == false && pr.StateDelete == false && pp.IdProduct == idproduct select new pGroups { IdParent = pr.IdParent }).Distinct().ToList(); var PropertyList = (from v in pGroups select new PropertyList { Subject = (from s in db.Property where s.Id == v.IdParent select new Propertylisted { Name = s.Name }).ToList(), Properties = (from _pp in db.ProductProperty join _pr in db.Property on _pp.IdProperty equals _pr.Id where _pp.StateDelete == false && _pr.IdParent == v.IdParent && _pp.IdProduct == idproduct select new ProductPropertylist { Key = _pr.Name, Value = _pp.Value }).ToList() }).ToList(); var _RelativeProduct = db.RelativeProduct.Where(p => p.StateDelete == false && p.IdProductMain == _mainproduct.Idparent).ToList() .Select(p => new ListRelativeProduct { Id = p.Id, ProductName = p.Product.Name, Url = p.Product.ProductImage.Where(q => q.IdProduct == p.IdProductSubmain).FirstOrDefault().Url }).ToList(); // List<RelativeProduct> _relativproduct = db.RelativeProduct.Where(p => p.StateDelete == false && p.IdProductSubmain == idproduct).ToList(); vmPrDetail _vmPrDetail = new vmPrDetail(); _vmPrDetail.Product = _Pr; _vmPrDetail.ImageProduct = ImageProduct; _vmPrDetail.pGroups = pGroups; _vmPrDetail.PropertyList = PropertyList; _vmPrDetail._mainproduct = _mainproduct; _vmPrDetail._relativeproduct = _RelativeProduct; return(_vmPrDetail); }