//[ChildActionOnly] public ActionResult getCategory() { model1 db = new model1(); List <Category> listDanhMuc = db.Categories.ToList <Category>(); return(PartialView(listDanhMuc)); }
public ActionResult ListProduct(int Iddanhmuc) { model1 db = new model1(); List <Product> listProduct = db.Products.Where(p => p.ID_DanhMuc == Iddanhmuc).ToList(); return(View(listProduct)); }
public ActionResult Index() { model1 db = new model1(); List <Product> listpro = db.Products.Take(10).ToList <Product>(); return(View(listpro)); }
public ActionResult ProductDetail(int Iddetail) { model1 db = new model1(); Product prodetail = db.Products.Where(p => p.ID_SanPham == Iddetail).SingleOrDefault(); return(View(prodetail)); }
public IActionResult SimpleBinding(model1 user) { if (ModelState.IsValid) { return(Content("validation complete!")); } else { return(View(user)); } }
private UserControl getBanner(bool chooseModel, Banner b1, Banner b2, Banner b3, Banner b4) { if (chooseModel) { return(new model1(b1, b2, b3, b4, chooseModel)); } else { var m = new model1(b1, b2, b3, b4, chooseModel); m.Switch(); return(m); } }
public ActionResult Register(RegisterModel user) { try { model1 db = new model1(); if (ModelState.IsValid == true) { UserManager usermanager = new UserManager(); if (usermanager.checkUserName(user.username) == false && usermanager.checkEmail(user.email) == false)/*chưa tồn tại nên tạo mới*/ { Account newuser = new Account(); newuser.UserName = user.username; newuser.Name = user.name; newuser.Password = user.password; newuser.Email = user.email; //newuser.SĐT = user.SĐT; //newuser.DiaChi = user.DiaChi; //mã hóa password SHA256 md5 = new SHA256CryptoServiceProvider(); Byte[] originalBytes = ASCIIEncoding.Default.GetBytes(newuser.Password); Byte[] encodedBytes = md5.ComputeHash(originalBytes); newuser.Password = BitConverter.ToString(encodedBytes); db.Accounts.Add(newuser); db.SaveChanges(); //ViewBag.dangkythanhcong = "Đã đăng ký thành công"; //return View(); Session["Register"] = "Đăng kí thành công"; return(RedirectToAction("Index", "Home")); } else { //return View("FailRegister"); ModelState.AddModelError("RegisterFail", "Tài khoản đã tồn tại"); ViewBag.error = "Tai khoan da ton tai"; } ViewBag.dangkythanhcong = "đã đăng ký thành công"; } } catch (Exception ex) { } return(View()); }
private model1[] InitDataSet() { model1[] ap = new model1[100]; StreamReader sR = new StreamReader(TrainDataPath, Encoding.UTF8); int i = 0; string nextLine; while ((nextLine = sR.ReadLine()) != null) { string[] data = nextLine.Split('\t'); ap[i] = new model1() { X1 = float.Parse(data[0]), X2 = float.Parse(data[1]), Class = int.Parse(data[2]) }; i++; } sR.Close(); return(ap); }
public string Contact(model1 m) { return(m.client_id); }
public IActionResult GetCarSite() { using (_dbContext) { var response = ResponseModelFactory.CreateResultInstance; #region 定位认证 //发送的参数 string url = "http://47.96.2.154/clbs/oauth/token"; model1 user = new model1(); user.client_id = "mobile_1"; user.client_secret = "secret_1"; user.grant_type = "password"; user.scope = "read"; user.username = "******"; user.password = "******"; var strPostData = ToPaeameter(user); var strResponse = PostUrl(url, strPostData); TrackToken usermodel = JsonConvert.DeserializeObject <TrackToken>(strResponse); #endregion var car = _dbContext.Car.Where(x => x.IsDelete != 1 && x.AddPeople == "狗").ToList(); var date = new ArrayList(); #region 获取定位 //发送参数 var name = string.Empty; var access_token = usermodel.value; for (int i = 0; i < car.Count; i++) { name = car[i].CarNum; var request = (HttpWebRequest)WebRequest.Create("http://47.96.2.154/clbs/swagger/m/monitoring/monitor/location/latest?name=" + name + "&access_token=" + access_token); request.Method = "GET"; //结果返回 var responses = (HttpWebResponse)request.GetResponse(); //转字符串 var responseString = new StreamReader(responses.GetResponseStream(), Encoding.UTF8).ReadToEnd(); //转换为json对象 Track commodel = JsonConvert.DeserializeObject <Track>(responseString); if (!string.IsNullOrEmpty(commodel.data[0].longitude.ToString()) && !string.IsNullOrEmpty(commodel.data[0].latitude.ToString())) { Guid caruuid = car[i].CarUuid; var log = ((double)commodel.data[0].longitude / (double)1000000).ToString(); var lat = ((double)commodel.data[0].latitude / (double)1000000).ToString(); #region 经纬度转换 var jwdrequest = (HttpWebRequest)WebRequest.Create("http://api.map.baidu.com/geoconv/v1/?coords=" + log + "," + lat + "&from=1&to=5&ak=nSxiPohfziUaCuONe4ViUP2N"); request.Method = "GET"; //结果返回 var jwdresponses = (HttpWebResponse)jwdrequest.GetResponse(); //转字符串 var jwdresponseString = new StreamReader(jwdresponses.GetResponseStream(), Encoding.UTF8).ReadToEnd(); //转换为json对象 JWDBaidu jwdcommodel = JsonConvert.DeserializeObject <JWDBaidu>(jwdresponseString); #endregion if (jwdcommodel.status == 0) { var query = new { name, lat = jwdcommodel.result[0].y.ToString(), lon = jwdcommodel.result[0].x.ToString(), cartype = car[i].CarType, grabtype = car[i].GrabType }; date.Add(query); } } } #endregion response.SetData(date); return(Ok(response)); } }