public async Task <IActionResult> PutFormulaModel(int id, FormulaModel formulaModel) { if (id != formulaModel.FormulaModelId) { return(BadRequest()); } _context.Entry(formulaModel).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FormulaModelExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public IActionResult insertFormula(string group_product, string group_material, string unit, string result_width, string result_long, string width_action_a, string width_action_a_val, string width_action_b, string width_action_b_val, string long_action_a, string long_action_a_val, string long_action_b, string long_action_b_val, string result_num, string width_x_long, string use_num) { checkVal ck = new checkVal(); FormulaModel fm = new FormulaModel(); fm.fm_ref_group_product_id = group_product; fm.fm_ref_group_material_id = group_material; fm.fm_ref_unit_id = unit; fm.fm_result_width = ck.trueORfalse(result_width); fm.fm_result_long = ck.trueORfalse(result_long); fm.fm_width_action_a = width_action_a; fm.fm_width_action_a_val = ck.numIsNull(width_action_a_val); fm.fm_width_action_b = width_action_b; fm.fm_width_action_b_val = ck.numIsNull(width_action_b_val); fm.fm_long_action_a = long_action_a; fm.fm_long_action_a_val = ck.numIsNull(long_action_a_val); fm.fm_long_action_b = long_action_b; fm.fm_long_action_b_val = ck.numIsNull(long_action_b_val); fm.fm_result_num = ck.trueORfalse(result_num); fm.fm_width_x_long = width_x_long; fm.fm_use_num = use_num; fm.insert_formula(); return(RedirectToAction("formula", "Formula")); }
public void del_formula(string id) { FormulaModel fm = new FormulaModel(); fm.fm_id = id; fm.del_formula(); }
public async Task <ActionResult <FormulaModel> > PostFormulaModel(FormulaModel formulaModel) { _context.FormulaModels.Add(formulaModel); await _context.SaveChangesAsync(); return(CreatedAtAction("GetFormulaModel", new { id = formulaModel.FormulaModelId }, formulaModel)); }
public void ParseFormula(FormulaModel model) { var parser = _serviceProvider.GetRequiredService <IFormulaParser>(); var res = parser.Parse(model.Formula); Assert.AreEqual(model.ParsedFormula, res.ToString()); }
public void CheckFormula(FormulaModel model) { var parser = _serviceProvider.GetRequiredService <IFormulaChecker>(); var res = parser.CheckSyntax(model.Formula); Assert.AreEqual(model.ExpectedOkResult, res.Ok); }
public void CalculateDateTimeFormula(FormulaModel model) { var evaluator = _serviceProvider.GetRequiredService <INoStringEvaluator>(); var res = evaluator.CalcDateTime(model.Formula, model.Arguments); Assert.AreEqual(model.Result, res); }
public string CalculateOperands(FormulaModel fm) { double result = 0.0; try { switch (fm.Operator) { case "+": result = fm.Operand1 + fm.Operand2; break; case "-": result = fm.Operand1 - fm.Operand2; break; case "*": result = fm.Operand1 * fm.Operand2; break; case "/": result = fm.Operand1 / fm.Operand2; break; default: break; } } catch (Exception e) { throw e.InnerException; } return(result.ToString()); }
public IActionResult formula() { FormulaModel fm = new FormulaModel(); ViewData["formula"] = fm.list_formula(); return(View()); }
public void CalculateNumberFormula(FormulaModel model) { var evaluator = _serviceProvider.GetRequiredService <INoStringEvaluator>(); var res = evaluator.CalcNumber(model.Formula, model.Arguments); var roundedRes = Math.Round(res, 3); Assert.AreEqual(model.Result, roundedRes); }
public void CalculateWordListFormula(FormulaModel model) { var evaluator = _serviceProvider.GetRequiredService <INoStringEvaluator>(); var res = evaluator.CalcWordList(model.Formula, model.Arguments); var sequenceEqual = model.Result.WordList.SequenceEqual(res); Assert.IsTrue(sequenceEqual); }
public FormulaViewModel(FormulaModel model, ImagesModel images, EquationViewModel parent) { this.model = model; this.formula = model.Formula; this.parent = parent; model.PropertyChanged += ModelOnPropertyChanged; images.PropertyChanged += ImagesOnPropertyChanged; parent.PropertyChanged += ParentOnPropertyChanged; }
private void PipelineFormulaOnPropertyChanged(ImagePipeline pipe, FormulaModel formula, PropertyChangedEventArgs e) { switch (e.PropertyName) { case nameof(FormulaModel.Converted): // verify if the new formula is still valid UpdateFormulaValidity(pipe, models.Images.NumImages); pipe.HasChanges = true; break; } }
/// <summary> /// Initialize the list of FormulaModel, close the window if list is empty. /// </summary> private void InitializeFormulas() { var lines = File.ReadAllLines(GlobalConfig.FormulasFile); foreach (string line in lines) { var lineParts = line.Split('|'); FormulaModel newFormula = new FormulaModel(lineParts[0].Replace('`', '|'), lineParts[1], lineParts[2]); formulas.Add(newFormula); } }
public async Task <ActionResult> AddFormula(OutModels.Models.Formula formula) { try { FormulaModel am = (FormulaModel)_mapper.Map <OutModels.Models.Formula, FormulaModel>(formula); return(new JsonResult(await this._repository.Insert(am))); } catch (Exception ex) { return(null); } }
public IActionResult Post([FromBody] FormulaModel model) { Guard.AgainstNull(model, nameof(model)); _bus.Send(new RegisterFormulaCommand { Id = model.Id, Name = model.Name }); return(Ok()); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(txtbox.Text)) { return; } FormulaModel model = new FormulaModel() { Txt = txtbox.Text, IsPass = true }; MainWindowViewModel.MainModel.FormulaList.Add(model); }
public void Add(FormulaModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into SaM_Formula("); builder.Append("FormulaID,FormulaName,Formula,AddDate)"); builder.Append(" values ("); builder.Append("@FormulaID,@FormulaName,@Formula,@AddDate)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@FormulaID", SqlDbType.NVarChar, 0x40), new SqlParameter("@FormulaName", SqlDbType.NVarChar, 0x20), new SqlParameter("@Formula", SqlDbType.NVarChar, 0x100), new SqlParameter("@AddDate", SqlDbType.DateTime) }; commandParameters[0].Value = model.FormulaID; commandParameters[1].Value = model.FormulaName; commandParameters[2].Value = model.Formula; commandParameters[3].Value = model.AddDate; SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters); }
public void Update(FormulaModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update SaM_Formula set "); builder.Append("FormulaName=@FormulaName,"); builder.Append("Formula=@Formula,"); builder.Append("AddDate=@AddDate"); builder.Append(" where FormulaID=@FormulaID "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@FormulaID", SqlDbType.NVarChar, 0x40), new SqlParameter("@FormulaName", SqlDbType.NVarChar, 0x20), new SqlParameter("@Formula", SqlDbType.NVarChar, 0x100), new SqlParameter("@AddDate", SqlDbType.DateTime) }; commandParameters[0].Value = model.FormulaID; commandParameters[1].Value = model.FormulaName; commandParameters[2].Value = model.Formula; commandParameters[3].Value = model.AddDate; SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters); }
public FormulaModel GetModel(string formulaID) { StringBuilder builder = new StringBuilder(); builder.Append("SELECT * FROM SaM_Formula "); builder.Append(" WHERE FormulaID=@in_FormulaID"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@in_FormulaID", SqlDbType.NVarChar, 0x40) }; commandParameters[0].Value = formulaID; FormulaModel model = null; using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), commandParameters)) { while (reader.Read()) { model = this.GetModel(reader); } return(model); } }
public async Task <IActionResult> Index(FormulaModel model) { if (!ModelState.IsValid) { return(View(model)); } _parser = new ParserWorker <RaceModel>(new FormulaParser()); _parser.Settings = new ParserSettings() { Link = model.Link }; RaceModel parsed = null; try { parsed = await _parser.Start(); ViewBag.ResultTable = parsed.ResultTable; } catch (Exception ex) { ModelState.AddModelError(nameof(model.Link), $"Ошибка при парсинге: {ex.Message}"); ViewBag.ResultTable = null; } if (parsed == null) { return(View(model)); } try { RacingInformation info = _racingRepository.Convert(parsed); await _racingRepository.Save(info); } catch { ModelState.AddModelError(nameof(model.Link), "Ошибка при сохранении данных"); } return(View(model)); }
public IActionResult editFormula(string id) { FormulaModel fm = new FormulaModel(); fm.select_formula("fm_id = '" + id + "'"); groupPoductModel gp = new groupPoductModel(); ViewData["group_product"] = gp.drop_gp(fm.fm_ref_group_product_id); groupMaterialModel gm = new groupMaterialModel(); ViewData["group_material"] = gm.drop_gm(fm.fm_ref_group_material_id); unitModel ut = new unitModel(); ViewData["unit"] = ut.drop_unit(fm.fm_ref_unit_id); ViewData["fm_id"] = id; checkVal ck = new checkVal(); ViewData["result_width"] = ck.turnTF(fm.fm_result_width); ViewData["result_long"] = ck.turnTF(fm.fm_result_long); ViewData["width_action_a"] = ck.ckFormula(fm.fm_width_action_a); ViewData["width_action_a_val"] = fm.fm_width_action_a_val; ViewData["width_action_b"] = ck.ckFormula(fm.fm_width_action_b); ViewData["width_action_b_val"] = fm.fm_width_action_b_val; ViewData["long_action_a"] = ck.ckFormula(fm.fm_long_action_a); ViewData["long_action_a_val"] = fm.fm_long_action_a_val; ViewData["long_action_b"] = ck.ckFormula(fm.fm_long_action_b); ViewData["long_action_b_val"] = fm.fm_long_action_b_val; ViewData["result_num"] = ck.turnTF(fm.fm_result_num); ViewData["width_x_long"] = fm.fm_width_x_long; ViewData["use_num"] = fm.fm_use_num; return(View()); }
public ActionResult Calc(FormCollection formCollection) { string result = string.Empty; CalculatorRepository calcRepository = new CalculatorRepository(); // Use a FormulaModel object to pass into CalculatorRepository FormulaModel formulaModel = new FormulaModel(); try { formulaModel.Operand1 = Convert.ToDouble(formCollection["Operand1"]); formulaModel.Operand2 = Convert.ToDouble(formCollection["Operand2"]); formulaModel.Operator = formCollection["Operator"]; ViewBag.Result = calcRepository.CalculateOperands(formulaModel); } catch (Exception e) { Response.Write(e.InnerException); } return(View()); }
public IActionResult Refresh(FormulaModel model) { return(RedirectToAction(nameof(Index))); }
private static FormulaModel[] CreateTestModelToCheck(string formula, bool expectedOkresult) { var model = new FormulaModel(formula, "NULL", double.NaN, expectedOkresult); return(new[] { model }); }
public void Add(FormulaModel model) { this.dal.Add(model); }
public void Update(FormulaModel model) { this.dal.Update(model); }
public ImagePipeline(int defaultImage) { Color = new FormulaModel(defaultImage); Alpha = new FormulaModel(defaultImage); }
public IActionResult Index() { var model = new FormulaModel(); return(View(model)); }
public FormulasController(ApplicationDbContext context) { _context = context; claseFormula = new FormulaModel(context); }