public IEnumerable <ModelViewModel> Get(int id) { return(EntityStore.Models.Include("Make").Include("Images") .Where(x => x.MakeId == id) .ToList() .Select(x => ModelViewModel.FromModel(x))); }
public HttpResponseMessage SearchModelsByMakeId(int makeId) { HttpResponseMessage response = new HttpResponseMessage(); try { var result = _dataService.SearchModelsByMakeId(makeId); MakeViewModel makeViewModel = new MakeViewModel(); makeViewModel.Id = result.Id; makeViewModel.Name = result.Name; makeViewModel.NiceName = result.NiceName; result.Models.ToList().ForEach(x => { ModelViewModel modelViewModel = new ModelViewModel(); modelViewModel.Id = x.Id; modelViewModel.Name = x.Name; modelViewModel.NiceName = x.NiceName; modelViewModel.Year = x.Year; makeViewModel.Models.Add(modelViewModel); }); response = Request.CreateResponse(HttpStatusCode.OK, makeViewModel); } catch (Exception ex) { response = Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.ToString()); return(response); } return(response); }
private static List <GeometryModel3D> GetModel(ModelRenderSet renderSet, Model model) { var geoModels = new List <GeometryModel3D>(); try { foreach (var groupKV in renderSet.Geometry.ModelPrimitiveGroups) { var group = groupKV.Value; var material = GetMaterial(group, model); if (material.Children.Count == 0) { continue; } var mesh = GetMesh(renderSet, group); var geoModel = new GeometryModel3D(); ModelViewModel.SetModel(geoModel, model); geoModel.Geometry = mesh; geoModel.Material = material; if (model.Type == Model.ModelType.Collision) { geoModel.BackMaterial = material; } geoModel.Freeze(); geoModels.Add(geoModel); } } catch (Exception) { Trace.WriteLine(string.Format("{0} can't render this group.", renderSet.Geometry.ModelPrimitiveGroups[0].Material.Fx)); } return(geoModels); }
public ActionResult AddNewModel(ModelViewModel model, HttpPostedFileBase uploadImage) { if (ModelState.IsValid) { if (uploadImage != null) { string writePath = Server.MapPath(@"~/Content/Images/Models/") + model.Name + ".jpg"; Image img = Image.FromStream(uploadImage.InputStream); img.Save(writePath); model.PhotoUrl = model.Name + ".jpg"; } model.BrandId = (int)TempData.Peek("BrandId"); try { modelService.AddModel(Mapper.Map <ModelViewModel, ModelDTO>(model)); } catch (ValidationException ex) { ViewBag.PropertyException = ex.Property; ViewBag.MessageException = ex.Message; ViewBag.BrandId = model.BrandId; return(View("ExceptionView")); } } return(RedirectToAction("Models", new RouteValueDictionary(new { controller = "Model", action = "Models", brandId = TempData["BrandId"] }))); }
public void Delete(ModelViewModel viewModel) { Model toRemove = EntityStore.Models.Find(viewModel.Id); EntityStore.Models.Remove(toRemove); EntityStore.SaveChanges(); }
public ActionResult DefineVariable() { //拿model string ProjectId = Convert.ToString(Session["ID"]); Projects data = projectservice.GetProjectData(ProjectId); ModelViewModel modelView = new ModelViewModel(); //讀檔案路徑的所有欄位名稱 Users user = userservice.FindUser(User.Identity.Name); string MapPath = filePath + user.Site + "/" + ProjectId + "/"; string path = MapPath + ProjectId; string file = path + "_pre.csv"; string[] lines = System.IO.File.ReadAllLines(file, Encoding.UTF8); modelView.ColList = lines[0].Trim().Split(',').Skip(2).ToArray(); //移除第一欄index、第二欄日期,存入下拉式選單 modelView.model = data.Model; modelView.ProjectId = ProjectId; //LSTM activationList String[] activations = { "tanh", "relu", "sigmoid", "hard_sigmoid", "softmax", "elu", "selu", "softplus", "softsign" }; modelView.activationList = activations; return(View(modelView)); }
internal MainWindowViewModel( ModelMetadata modelMetadata, ILatestVersionService latestVersionService, IMainWindowService mainWindowService, ModelViewModel modelViewModel, OpenModelViewModel openModelViewModel, IOpenModelService openModelService, IRecentModelsService recentModelsService, IModelMetadataService modelMetadataService, IStartInstanceService startInstanceService, IModelViewService modelViewService, IProgressService progress) { this.modelMetadata = modelMetadata; this.mainWindowService = mainWindowService; this.openModelService = openModelService; this.recentModelsService = recentModelsService; this.modelMetadataService = modelMetadataService; this.startInstanceService = startInstanceService; this.modelViewService = modelViewService; this.progress = progress; ModelViewModel = modelViewModel; OpenModelViewModel = openModelViewModel; modelMetadata.OnChange += (s, e) => Notify(nameof(MainTitle)); latestVersionService.OnNewVersionAvailable += (s, e) => IsNewVersionVisible = true; latestVersionService.StartCheckForLatestVersion(); SearchItems = new ObservableCollection <SearchEntry>(); ClearSelectionItems(); }
public ActionResult ChooseModel(ModelViewModel data) { if (data.mode == "1") { //儲存選擇的model modelservice.SaveModel(Convert.ToString(Session["ID"]), data.model); //更新執行步驟&時間 modelservice.UpdateProcess(Convert.ToString(Session["ID"]), 3); return(RedirectToAction("DefineVariable", "Model")); } else if (data.mode == "2") { //predict string ProjectId = Convert.ToString(Session["ID"]); Users user = userservice.FindUser(User.Identity.Name); string MapPath = filePath + user.Site + "/" + ProjectId + "/"; string path = MapPath; string arg = ""; Model moedeldata = modelservice.GetModelData(ProjectId, data.model); if (projectservice.GetProjectData(ProjectId).Model == "LSTM") { arg = $"{pyPath}LSTM_predict_v3.py {path + data.model.Replace("\r\n", "") + ".h5"} {path + ProjectId + "_predict_pre.csv"} {moedeldata.y} {path + "min_max.csv"} {path}"; } else { arg = $"{pyPath}predict_v3.py {path + ProjectId + "_predict_pre.csv"} {path + "min_max.csv"} {path + data.model.Replace("\r\n", "") + ".h5"} {moedeldata.y} {path} "; } callpython.CMD(); string output = callpython.Execute(arg); return(RedirectToAction("PredictResult", "Model")); } return(View(data)); }
public ActionResult ChooseModel(DataPreprocess data) { ModelViewModel modelView = new ModelViewModel(); modelView.cantfill = data.cantfill; modelView.ProjectId = Convert.ToString(Session["ID"]); modelView.mode = Convert.ToString(Session["Mode"]); if (modelView.mode == "2") { Users user = userservice.FindUser(User.Identity.Name); string MapPath = filePath + user.Site + "/" + modelView.ProjectId + "/"; string path = MapPath; //判斷train, predict資料欄位是否一致 var file1 = Directory.GetFiles(path, modelView.ProjectId + "_pre.csv", SearchOption.AllDirectories); var file2 = Directory.GetFiles(path, "*predict_pre.csv", SearchOption.AllDirectories); string[] lines1 = System.IO.File.ReadAllLines(file1[0], Encoding.UTF8); string[] lines2 = System.IO.File.ReadAllLines(file2[0], Encoding.UTF8); bool compare = lines1[0].SequenceEqual(lines2[0]); if (compare == false) { return(RedirectToAction("ProjectList", "Project", new { compare = compare })); } modelView.ModelList = modelservice.GetAllModelList(modelView.ProjectId).ToList(); string file = path + modelView.ProjectId + "_predict_pre.csv"; string[] lines = System.IO.File.ReadAllLines(file, Encoding.UTF8); modelView.ColList = lines[0].Trim().Split(',').Skip(2).ToArray(); //移除index, date,存入下拉式選單 } return(View(modelView)); }
public ImportModPackWizard(ModPackJson modPackJson, Dictionary <string, Image> imageDictionary, DirectoryInfo modPackDirectory, TextureViewModel textureViewModel, ModelViewModel modelViewModel, bool messageInImport = false) { InitializeComponent(); _imageDictionary = imageDictionary; _modPackDirectory = modPackDirectory; _messageInImport = messageInImport; _textureViewModel = textureViewModel; _modelViewModel = modelViewModel; ModPackNameLabel.Content = modPackJson.Name; ModPackAuthorLabel.Content = modPackJson.Author; ModPackVersionLabel.Content = modPackJson.Version; ModPackDescription.Text = modPackJson.Description; _modPackEntry = new ModPack { name = modPackJson.Name, author = modPackJson.Author, version = modPackJson.Version }; _pageCount = modPackJson.ModPackPages.Count; var wizPages = importModPackWizard.Items; for (var i = 0; i < _pageCount; i++) { wizPages.Add(new WizardPage { Content = new ImportWizardModPackControl(modPackJson.ModPackPages[i], imageDictionary), PageType = WizardPageType.Blank, Background = null, HeaderBackground = null }); } }
public ActionResult EditModel(ModelViewModel model, HttpPostedFileBase uploadImage) { if (ModelState.IsValid) { if (uploadImage != null) { string writePath = Server.MapPath(@"~/Content/Images/Models/") + model.Name + ".jpg"; Image img = Image.FromStream(uploadImage.InputStream); img.Save(writePath); model.PhotoUrl = model.Name + ".jpg"; } else { model.PhotoUrl = (modelService.GetModel(model.Id)).PhotoUrl; } model.BrandId = (int)TempData.Peek("BrandId"); modelService.UpdateModel(Mapper.Map <ModelViewModel, ModelDTO>(model)); } return(RedirectToAction("Models", new RouteValueDictionary(new { controller = "Model", action = "Models", brandId = TempData["BrandId"] }))); }
public IEnumerable <ModelViewModel> GetAll() { List <ModelViewModel> models = new List <ModelViewModel>(); using (SqlConnection conn = new SqlConnection()) { conn.ConnectionString = _connection; SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "GetAllModels"; cmd.CommandType = CommandType.StoredProcedure; conn.Open(); using (SqlDataReader dr = cmd.ExecuteReader()) { while (dr.Read()) { ModelViewModel current = new ModelViewModel(); current.ModelId = (int)dr["ModelId"]; current.ModelName = dr["ModelName"].ToString(); current.MakeName = dr["MakeName"].ToString(); current.DateAdded = (DateTime)dr["DateAdded"]; current.EmailOfAdder = dr["EmailOfAdder"].ToString(); models.Add(current); } } } return(models); }
// GET: Products/Edit/5 public async Task <IActionResult> Edit(int?id, string message) { if (id == null) { return(NotFound()); } var model = await db.Models .Include(m => m.Products) .Include(m => m.Collection) .SingleOrDefaultAsync(m => m.ModelId == id); if (model == null) { return(NotFound()); } ViewBag.Message = message; await FillDataListViewBags(); ModelViewModel modelViewModel = new ModelViewModel { ModelId = model.ModelId, Name = model.Name, Collection = model.Collection.Name, Photo1 = Convert.ToBase64String(model.Photo1), Photo2 = Convert.ToBase64String(model.Photo2) }; ViewBag.Products = model.Products; return(View(modelViewModel)); }
public ActionResult Edit(ModelViewModel modelData) { if (ModelState.IsValid) { MODEL model = new MODEL() { ID = modelData.ID, ID_TYPE = modelData.ID_TYPE, NAME = modelData.NAME }; modelRepository.Update(model); modelRepository.Save(); if (modelData.currentCoast != modelData.oldCoast) { PRICE price = new PRICE() { COAST = Convert.ToDecimal(modelData.currentCoast), ID_MODEL = Convert.ToDecimal(modelData.ID), DATE_ADD = DateTime.Now }; priceRepository.Create(price); priceRepository.Save(); } return(RedirectToAction("Index")); } return(View(modelData)); }
private void UpdateMaintenanceItemDetail(ModelViewModel model) { List <MaintenanceItemDetailViewModel> newMaintenaceItems = model.MaintenanceItems; var deleteItems = _maintenanceItemDetailRepository.GetAll().Where(x => x.ObjectI.Equals(model.ObjectI) && x.ModelC == model.ModelC); if (deleteItems.Any()) { foreach (var item in deleteItems) { _maintenanceItemDetailRepository.Delete(item); } } //add foreach (var item in newMaintenaceItems) { var addItem = new MaintenanceItem_D() { DisplayLineNo = item.DisplayLineNo, MaintenanceItemC = item.MaintenanceItemC, ModelC = item.ModelC, ObjectI = item.ObjectI }; _maintenanceItemDetailRepository.Add(addItem); } }
// Get: Edit public ActionResult Edit(int?id) { if (id == null) { return(HttpNotFound()); } MODEL model = modelRepository.GetAllList(). FirstOrDefault(x => x.ID.Equals(Convert.ToDecimal(id))); if (model == null) { return(HttpNotFound()); } decimal coast = model.PRICE.Where(x => x.ID_MODEL.Equals(model.ID)) .OrderByDescending(x => x.DATE_ADD).FirstOrDefault().COAST; ModelViewModel modelData = new ModelViewModel() { ID = model.ID, ID_TYPE = model.ID_TYPE, NAME = model.NAME, typeList = getList.getTypeSelectList(), currentCoast = coast, oldCoast = coast }; return(View(modelData)); }
public SimpleModPackImporter(DirectoryInfo modPackDirectory, ModPackJson modPackJson, TextureViewModel textureViewModel, ModelViewModel modelViewModel, bool silent = false, bool messageInImport = false) { this.DataContext = this; InitializeComponent(); JsonEntries = new List <ModsJson>(); SelectedEntries = new HashSet <int>(); _modPackDirectory = modPackDirectory; _gameDirectory = new DirectoryInfo(Properties.Settings.Default.FFXIV_Directory); _modding = new Modding(_gameDirectory); _texToolsModPack = new TTMP(new DirectoryInfo(Properties.Settings.Default.ModPack_Directory), XivStrings.TexTools); _messageInImport = messageInImport; _textureViewModel = textureViewModel; _modelViewModel = modelViewModel; var index = new Index(_gameDirectory); _indexLockStatus = index.IsIndexLocked(XivDataFile._0A_Exd); _packJson = modPackJson; _silent = silent; ModListView.IsEnabled = false; LockedStatusLabel.Foreground = Brushes.Black; LockedStatusLabel.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; LockedStatusLabel.Content = UIStrings.Loading; Task.Run(Initialize); }
public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } var model = await db.Models .Include(p => p.Collection) .Include(p => p.Products) .SingleOrDefaultAsync(m => m.ModelId == id); if (model == null) { return(NotFound()); } ModelViewModel modelViewModel = new ModelViewModel { ModelId = model.ModelId, Collection = model.Collection.Name, Photo1 = Convert.ToBase64String(model.Photo1), Photo2 = Convert.ToBase64String(model.Photo2) }; return(View(modelViewModel)); }
public async Task <IActionResult> Create(ModelViewModel modelViewModel) { if (ModelState.IsValid) { Model model = new Model { CollectionId = await GetOrCreateCollection(modelViewModel.Collection), Name = modelViewModel.Name, Photo1 = Convert.FromBase64String(modelViewModel.Photo1.Split(",")[1]), Photo2 = Convert.FromBase64String(modelViewModel.Photo2.Split(",")[1]) }; try { db.Models.Add(model); await db.SaveChangesAsync(); } catch (Exception ex) { return(RedirectToAction(nameof(Create), new { message = $"Errors in adding model. Error message: {ex.Message}" })); } return(RedirectToAction(nameof(Index))); } await FillDataListViewBags(); return(View(modelViewModel)); }
public async Task <IActionResult> Edit(ModelViewModel modelViewModel) { if (ModelState.IsValid) { Model model = db.Models.Find(modelViewModel.ModelId); if (model == null) { return(NotFound()); } model.CollectionId = await GetOrCreateCollection(modelViewModel.Collection); model.Name = modelViewModel.Name; model.Photo1 = Convert.FromBase64String(modelViewModel.Photo1.Split(",")[1]); model.Photo2 = Convert.FromBase64String(modelViewModel.Photo2.Split(",")[1]); try { db.Models.Update(model); await db.SaveChangesAsync(); } catch (Exception ex) { return(RedirectToAction(nameof(Edit), new { id = modelViewModel.ModelId, message = $"Errors in editing product. Error message: {ex.Message}" })); } return(RedirectToAction(nameof(Index))); } await FillDataListViewBags(); return(View(modelViewModel)); }
public void LoadFrom(ModelViewModel data) { if (data != null) { Guid = data.Guid; } }
public void Put(string id, [FromBody] ModelViewModel m) { // [TEMP] UserId 채우기 m.User = GetCurrentUser(); service.Update(m); }
public ModListView(TextureViewModel textureViewModel, ModelViewModel modelViewModel) { _textureViewModel = textureViewModel; _modelViewModel = modelViewModel; InitializeComponent(); }
public ActionResult Modells() { var model = new ModelViewModel(); model.Models = ctxs.GetAllModel(); model.SetMakeItems(CarFactory.Create().GetAllMakes()); return(View(model)); }
public async Task <IActionResult> Index() { var model = new ModelViewModel(); model.Models = await _dataRepo.GetList <Model>(); return(View(model)); }
public ActionResult RemoveModel(int id, string modelName) { var model = new ModelViewModel { Id = id, Name = modelName }; return(PartialView("RemoveModel", model)); }
// GET: Model/Edit/5 public ActionResult Edit(int id) { loadBrand(); ModelViewModel modelViewModel = ModelServices.GetById(id); return(View(modelViewModel)); }
public ActionResult AddModel(ModelViewModel mb) { saf.Add(mb); List <ModelViewModel> s = saf.GetAll(); Session["ListAllModel"] = s; return(RedirectToAction("ModelViewAll")); }
// Get: Create public ActionResult Create() { ModelViewModel modelData = new ModelViewModel() { typeList = getList.getTypeSelectList() }; return(View(modelData)); }
public ModelController(VroomDbContext db) { _db = db; ModelVM = new ModelViewModel() { Makes = _db.Makes.ToList(), Model = new Models.Model() }; }