public void validate_default() { InstructionViewModel viewModel = new InstructionViewModel(); var result = viewModel.Validate(null); Assert.True(0 < result.Count()); }
public MainWindow() { this.InitializeComponent(); // Insert code required on object creation below this point. instruction_view_model = (InstructionViewModel)this.FindResource("instruction_view_model"); }
public async Task <ActionResult> AddInstruction(int?id) { if (!id.HasValue) { return(RedirectToAction("Index", "QualityControl")); } Expression <Func <Instruction, bool> > expr = (i => i.QualityControlId == id); var instructions = await _unitOfWork.InstructionRepository.GetAsync(expr); var control = await _unitOfWork.QualityControlRepository.FindByIdAsync(id); if (control == null) { return(HttpNotFound()); } var vm = new InstructionViewModel { QualityControlId = id.Value, Instructions = instructions, CanSave = control.Status == QualityControlStatus.Closed ? false : true }; return(View(vm)); }
public async Task <ActionResult> AddInstruction(InstructionViewModel vm) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Data is invalid"); return(View(vm)); } var control = await _unitOfWork.QualityControlRepository.FindByIdAsync(vm.QualityControlId); if (control == null) { return(HttpNotFound()); } try { var user = await GetUserAsync(); var instruction = _factory.Create(vm, user); control.AddInstruction(instruction, user); await _unitOfWork.SaveChangesAsync(); vm.Name = vm.Description = vm.Comments = ""; } catch (Exception ex) { await LogExceptionAsync(ex); return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message)); } vm.Instructions = control.Instructions; return(View(vm)); }
public ActionResult New() { var instructionViewModel = new InstructionViewModel(); instructionViewModel.ProductDtos = productService.GetAll(); return(View("InstructionForm", instructionViewModel)); }
public void Flash(IEnumerable <string> firmware, bool newFirmware) { Simulation.Error = "Error stopping audio player"; if (this.Loaded) { Reset(); } Simulation.Error = "Error decoding hex file"; var decoder = new HexDecoder(); int minAddr, maxAddr; decoder.Decode(firmware, out minAddr, out maxAddr); this.MinAddr = minAddr; this.MaxAddr = maxAddr; // add the disassembled instructions Simulation.Error = "Error dissassembling hex file"; this.Disassembly = new List <InstructionViewModel>(); this.Instructions = new Dictionary <int, InstructionViewModel>(); int hide = 0; for (int i = 0; i < AtmelContext.Flash.Length; i++) { var vm = new InstructionViewModel(this, i); if (hide > 0) { vm.Hidden = true; hide--; } else { hide += vm.Size - 1; } this.Disassembly.Add(vm); this.Instructions[i] = vm; } Simulation.Error = "Error initializing breakpoints"; if ((this.Breakpoints == null) || newFirmware) { this.Breakpoints = new Boolean[this.Disassembly.Count()]; } else { Array.Resize(ref this.Breakpoints, this.Disassembly.Count()); for (int i = 0; i < this.Disassembly.Count(); i++) { this.Disassembly[i].Breakpoint = this.Breakpoints[i]; } } this.Loaded = (this.MinAddr >= 0) && (this.MaxAddr < 2 * AtmelContext.Flash.Length) && (this.MaxAddr > this.MinAddr); Simulation.Error = "Error performing initial flash update"; Update(); }
public static InstructionEntity ToBll(this InstructionViewModel model) { return(new InstructionEntity() { Id = model.Id, Name = model.Name, Description = model.Description, IsSupported = model.IsSupported }); }
public Instruction Create(InstructionViewModel model, User user) { return(new Instruction(user) { QualityControlId = model.QualityControlId, Name = model.Name, Description = model.Description, Comments = model.Comments, Status = InstructionStatus.Pending }); }
public ActionResult Update(InstructionViewModel model) { try { _service.Update(model.ToBll()); } catch (ServiceException ex) { return(Json(new { answer = ex.Message, success = false })); } return(Json(new { answer = "Instruction updated successfully.", success = true })); }
public FilterWindow() { InitializeComponent(); /* Restore any existing filter state */ low_instruction_enabled.IsChecked = (bool)Application.Current.Resources["filter_instruction_low_enabled"]; if ((bool)low_instruction_enabled.IsChecked) { uint filter_low; UInt32.TryParse(Application.Current.Resources["filter_instruction_low"].ToString(), out filter_low); low_instruction.Text = filter_low.ToString("X"); } high_instruction_enabled.IsChecked = (bool)Application.Current.Resources["filter_instruction_high_enabled"]; if ((bool)high_instruction_enabled.IsChecked) { uint filter_high; UInt32.TryParse(Application.Current.Resources["filter_instruction_high"].ToString(), out filter_high); high_instruction.Text = filter_high.ToString("X"); } low_depth_enabled.IsChecked = (bool)Application.Current.Resources["filter_depth_low_enabled"]; if ((bool)low_depth_enabled.IsChecked) { low_depth.Text = (Application.Current.Resources["filter_depth_low"]).ToString(); } high_depth_enabled.IsChecked = (bool)Application.Current.Resources["filter_depth_high_enabled"]; if ((bool)high_depth_enabled.IsChecked) { high_depth.Text = (Application.Current.Resources["filter_depth_high"]).ToString(); } library_name_enabled.IsChecked = (bool)Application.Current.Resources["filter_libraries_included_enabled"]; if (library_name_enabled.IsChecked.HasValue && (bool)library_name_enabled.IsChecked) { InstructionViewModel ivm = (InstructionViewModel)this.FindResource("instruction_view_model"); library_name.SelectedItems.Clear(); foreach (string i in ivm.Library_names) { library_name.SelectedItems.Add(i); } } thread_id_enabled.IsChecked = (bool)Application.Current.Resources["filter_threads_included_enabled"]; if ((bool)thread_id_enabled.IsChecked) { InstructionViewModel ivm = (InstructionViewModel)this.FindResource("instruction_view_model"); thread_id.SelectedItems.Clear(); foreach (uint i in ivm.Thread_ids) { thread_id.SelectedItems.Add(i); } } system_call_enabled.IsChecked = (bool)Application.Current.Resources["filter_system_calls_enabled"]; }
public void validate_Steps() { var steps = new List <StepViewModel>() { new StepViewModel() }; InstructionViewModel viewModel = new InstructionViewModel() { Steps = steps }; var result = viewModel.Validate(null); Assert.True(0 < result.Count()); }
public void Mapping_With_AutoMapper_Profiles() { var configuration = new MapperConfiguration(cfg => { cfg.AddProfile <InstructionProfile>(); }); var mapper = configuration.CreateMapper(); InstructionViewModel vm = new InstructionViewModel { Id = 1 }; InstructionModel model = mapper.Map <InstructionModel>(vm); Assert.Equal(vm.Id, model.Id); }
public JsonResult Delete([FromBody] InstructionViewModel vm) { try { var instruction = Mapper.Map <Instruction>(vm); _instructionsRepository.Delete(instruction); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(true)); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = $"An error occurred - {ex.Message}" })); } }
protected override void InitializeMockData() { control = new QualityControl { Id = 1, Name = "Dimensional Control", Description = "Control dimensions DIM312 in CMM3", Instructions = new List <Instruction>(), Status = QualityControlStatus.Open }; viewModel = new InstructionViewModel { QualityControlId = 1, Name = "CMM", Description = "Control dimension DI312", Comments = "N/A" }; }
public void Should_Success_Instantiate() { var steps = new List <StepViewModel>() { new StepViewModel() }; InstructionViewModel viewModel = new InstructionViewModel() { UId = "UId", Code = "Code", Name = "Name", Steps = steps }; Assert.Equal("UId", viewModel.UId); Assert.Equal("Code", viewModel.Code); Assert.Equal("Name", viewModel.Name); Assert.Equal(steps, viewModel.Steps); }
public ActionResult Save(InstructionViewModel instructionViewModel) { var instructionDto = Mapper.Map <InstructionDto>(instructionViewModel); if (!ModelState.IsValid) { instructionViewModel = new InstructionViewModel(); return(View("InstructionForm", instructionViewModel)); } if (instructionDto.Id == 0) { instructionService.Add(instructionDto); } else { instructionService.Edit(instructionDto); } return(RedirectToAction("Index", "Instructions")); }
private void apply_filters(object sender, RoutedEventArgs e) { LibraryViewModel global_library_list = (LibraryViewModel)this.FindResource("library_view_model"); InstructionViewModel global_instruction_list = (InstructionViewModel)this.FindResource("instruction_view_model"); FilterWindow filter = new FilterWindow(); foreach (Library l in global_library_list.Model) { filter.library_name.Items.Add(l.Library_name); } foreach (Instruction i in global_instruction_list.Model) { if (!filter.thread_id.Items.Contains(i.Thread_id)) { filter.thread_id.Items.Add(i.Thread_id); } } filter.Show(); filter.Closed += filter_Closed; }
public JsonResult Put([FromBody] InstructionViewModel vm) { try { if (ModelState.IsValid) { var instruction = Mapper.Map <Instruction>(vm); _instructionsRepository.Update(instruction); var instructionViewModel = Mapper.Map <InstructionViewModel>(instruction); Response.StatusCode = (int)HttpStatusCode.OK; return(Json(instructionViewModel)); } Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = $"Invalid model state", Errors = GetModelStateErrors() })); } catch (Exception ex) { Response.StatusCode = (int)HttpStatusCode.BadRequest; return(Json(new { Message = $"An error occurred - {ex.Message}" })); } }
private void apply_filter_button(object sender, RoutedEventArgs e) { InstructionViewModel ivm = (InstructionViewModel)this.FindResource("instruction_view_model"); UInt32 filter_instruction_low = new UInt32(); filter_instruction_low = 0x40000000; Application.Current.Resources["filter_instruction_low"] = filter_instruction_low; filter_instruction_low = (UInt32)this.FindResource("filter_instruction_low"); Application.Current.Resources["filter_instruction_low_enabled"] = low_instruction_enabled.IsChecked; Application.Current.Resources["filter_instruction_high_enabled"] = high_instruction_enabled.IsChecked; Application.Current.Resources["filter_depth_low_enabled"] = low_depth_enabled.IsChecked; Application.Current.Resources["filter_depth_high_enabled"] = high_depth_enabled.IsChecked; Application.Current.Resources["filter_libraries_included_enabled"] = library_name_enabled.IsChecked; Application.Current.Resources["filter_threads_included_enabled"] = thread_id_enabled.IsChecked; Application.Current.Resources["filter_system_calls_enabled"] = system_call_enabled.IsChecked; UInt32 result_uint; if ((bool)low_instruction_enabled.IsChecked) { if (UInt32.TryParse(low_instruction.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result_uint)) { Application.Current.Resources["filter_instruction_low"] = result_uint; } else { MessageBox.Show("Couldn't parse low disk instruction cutoff! Hex, no leading 0x"); return; } } if ((bool)high_instruction_enabled.IsChecked) { if (UInt32.TryParse(high_instruction.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result_uint)) { Application.Current.Resources["filter_instruction_high"] = result_uint; } else { MessageBox.Show("Couldn't parse high disk instruction cutoff! Hex, no leading 0x"); return; } } Int32 result_int; if ((bool)low_depth_enabled.IsChecked) { if (Int32.TryParse(low_depth.Text, out result_int)) { Application.Current.Resources["filter_depth_low"] = result_int; } else { MessageBox.Show("Couldn't parse low filter depth! Decimal format only. "); return; } } if ((bool)high_depth_enabled.IsChecked) { if (Int32.TryParse(high_depth.Text, out result_int)) { Application.Current.Resources["filter_depth_high"] = result_int; } else { MessageBox.Show("Couldn't parse high filter depth! Decimal format only. "); return; } } if ((bool)library_name_enabled.IsChecked) { ivm.Library_names.Clear(); foreach (string s in library_name.SelectedItems) { ivm.Library_names.Add(s); } } if ((bool)thread_id_enabled.IsChecked) { ivm.Thread_ids.Clear(); foreach (uint i in thread_id.SelectedItems) { ivm.Thread_ids.Add(i); } } this.Close(); }
public InstructionPage() { InitializeComponent(); ViewModel = new InstructionViewModel(VideoView); }
public static void SetCurrentInstruction(UIElement element, InstructionViewModel value) { element.SetValue(CurrentInstructionProperty, value); }