public void SetupTravelPass(TravelPass travelPass) { LoadDataMachinist(); LoadDataTrainRoute(); LoadDataStation(); // Debug.Log("Travel Pass Machinist Id: " + travelPass.MachinistId); travelPassForm.SetActive(true); idIF.text = travelPass.Id; //Find Machinist Machinist machinist = new Machinist(); for (int i = 0; i < machinists.Count; i++) { if (machinists[i].Id == travelPass.MachinistId) { machinist = machinists[i]; } } //Find Train Route TrainRoute trainRoute = new TrainRoute(); for (int i = 0; i < trainRoutes.Count; i++) { if (trainRoutes[i].Id == travelPass.TrainRouteId) { trainRoute = trainRoutes[i]; } } machinistIF.text = machinist.Name; trainRouteIF.text = trainRoute.Name; }
public ActionResult DeleteConfirmed(int id) { Machinist machinist = db.Machinist.Find(id); db.Machinist.Remove(machinist); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "idMachinist,FIO,DateBirth,Address,Category,Telephone")] Machinist machinist) { if (ModelState.IsValid) { db.Entry(machinist).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(machinist)); }
public ActionResult Create([Bind(Include = "idMachinist,FIO,DateBirth,Address,Category,Telephone")] Machinist machinist) { if (ModelState.IsValid) { db.Machinist.Add(machinist); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(machinist)); }
// GET: Machinists/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Machinist machinist = db.Machinist.Find(id); if (machinist == null) { return(HttpNotFound()); } return(View(machinist)); }
public ActionResult Import(HttpPostedFileBase excelfile) { Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); if (excelfile == null || excelfile.ContentLength == 0) { ViewBag.Error = "Файл не выбран! <br>"; return(View("Index", db.AspNetUsers.ToList())); } else { if (excelfile.FileName.EndsWith("xls") || excelfile.FileName.EndsWith("xlsx")) { db = new TTCEntities(); string path = Server.MapPath("~/Import/" + excelfile.FileName); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } excelfile.SaveAs(path); //Читаем из файла // Excel.Application ap = new Excel.Application(); Excel.Application application = new Excel.Application(); Excel.Workbook workbook = application.Workbooks.Open(path); Excel.Worksheet worksheet = workbook.ActiveSheet; Excel.Range range = worksheet.UsedRange; List <Machinist> listUsers = new List <Machinist>(); for (int row = 2; row <= range.Rows.Count; row++) { Machinist user = new Machinist(); user.FIO = ((Excel.Range)range.Cells[row, 1]).Text; user.Address = ((Excel.Range)range.Cells[row, 2]).Text; user.Telephone = ((Excel.Range)range.Cells[row, 3]).Text; db.Machinist.Add(user); db.SaveChanges(); } workbook.Close(); ViewBag.Error = "Данные загружены <br>"; return(View("Index", db.Machinist.ToList())); } else { ViewBag.Error = "Это не Excel! <br>"; return(View("Index", db.Machinist.ToList())); } } }
[ValidateAntiForgeryToken] // Prevent Cross Site Request Forgery (CSRF) Attacks by generating and comparing Token automatically public ActionResult Save( [Bind(Include = "Id, FirstName, LastName, Email, Phone, AddressId")] Machinist machinist, [Bind(Include = "Id, Address1, Address2, City, Country, ZipCode")] Address address) { if (!ModelState.IsValid) { var viewModel = new MachinistViewModel { Machinist = machinist, Address = address }; return(View("MachinistsForm", viewModel)); } // if new machinist if (machinist.Id == 0) { _context.Address.Add(address); _context.SaveChanges(); machinist.AddressId = address.Id; _context.Machinist.Add(machinist); TempData[Constant.Success] = Constant.New; } // if modify existing machinist else { var MachinistDB = _context.Machinist.Single(c => c.Id == machinist.Id); var addressDB = _context.Address.Single(a => a.Id == address.Id); addressDB.Address1 = address.Address1; addressDB.Address2 = address.Address2; addressDB.ZipCode = address.ZipCode; addressDB.City = address.City; addressDB.Country = address.Country; MachinistDB.FirstName = machinist.FirstName; MachinistDB.LastName = machinist.LastName; MachinistDB.Email = machinist.Email; MachinistDB.Phone = machinist.Phone; machinist.IsAvailable = true; TempData[Constant.Success] = Constant.Update; } _context.SaveChanges(); return(RedirectToAction("Index", "Machinist")); }
private void InitializeMachineFor(Machinist machine, string proxyParam, string smoothingParam, string zeroClip, string oneClip) { var proxyTree = InterpolationTree(proxyParam, zeroClip, oneClip); RegisterBlendTreeAsAsset(_animatorController, proxyTree); var smoothingTree = InterpolationTree(smoothingParam, zeroClip, oneClip); RegisterBlendTreeAsAsset(_animatorController, smoothingTree); var factorTree = new BlendTree { name = "autoBT_Factor_" + proxyParam + "", blendParameter = SharedLayerUtils.HaiGestureComboSmoothingFactor, blendType = BlendTreeType.Simple1D, minThreshold = 0, maxThreshold = 1, useAutomaticThresholds = true, children = new[] { new ChildMotion { motion = proxyTree, timeScale = 1, threshold = 0 }, new ChildMotion { motion = smoothingTree, timeScale = 1, threshold = 1 } }, hideFlags = HideFlags.HideInHierarchy }; RegisterBlendTreeAsAsset(_animatorController, factorTree); machine.NewState("Interpolating", 1, 1) .WithAnimation(factorTree) .WithWriteDefaultsSetTo(_writeDefaultsForAnimatedAnimatorParameterStates) .Drives(new FloatParameterist(SharedLayerUtils.HaiGestureComboSmoothingFactor), DefaultSmoothingFactor); }