//private readonly ApplicationDataContext _dataContext; public string GetSummation(DataInputViewModel model) { string Summation = ""; if (model.Number1.StartsWith("-") && model.Number2.StartsWith("-")) { Summation = GetSummationOfNumbers(model.Number1.Replace("-", ""), model.Number2.Replace("-", "")); Summation = "-" + Summation; } else if ((model.Number1.StartsWith("-") && !model.Number2.StartsWith("-")) || (!model.Number1.StartsWith("-") && model.Number2.StartsWith("-"))) { Summation = GetDifference(model.Number1.Replace("-", ""), model.Number2.Replace("-", ""), model.Number1.StartsWith("-"), model.Number2.StartsWith("-")); //if (Summation != "0" && isSmaller(model.Number1.Replace("-", ""), model.Number2.Replace("-", "")) && model.Number2.StartsWith("-")) //{ // Summation = "-" + Summation; //} //else if (Summation != "0" && !isSmaller(model.Number1.Replace("-", ""), model.Number2.Replace("-", "")) && model.Number1.StartsWith("-")) //{ // Summation = "-" + Summation; //} } else { Summation = GetSummationOfNumbers(model.Number1, model.Number2); } return(Summation); }
public DataInput CreateDataInput(DataInputViewModel viewModel) { if (viewModel == null) { throw new ArgumentNullException(nameof(viewModel)); } var dataInput = new DataInput { Identifier = viewModel.ProcessName, MimeType = viewModel.SelectedFormat?.MimeType ?? "", Schema = viewModel.SelectedFormat?.SelectedSchema ?? "", Encoding = viewModel.SelectedFormat?.SelectedEncoding ?? "", }; if (viewModel.IsReference) { dataInput.Reference = new ResourceReference { Href = viewModel.ReferenceUrl }; } else { if (viewModel is LiteralInputViewModel lvm) { dataInput.Data = new LiteralDataValue { Value = lvm.Value }; } else if (viewModel is BoundingBoxInputViewModel bvm) { dataInput.Data = new BoundingBoxValue { DimensionCount = 2, LowerCornerPoints = new[] { bvm.RectangleViewModel.LeftBottom.Item1, bvm.RectangleViewModel.LeftBottom.Item2 }, UpperCornerPoints = new[] { bvm.RectangleViewModel.RightTop.Item1, bvm.RectangleViewModel.RightTop.Item2 }, }; } else if (viewModel is ComplexDataViewModel cvm) { if (cvm.IsFile) { var inputFileData = _fileReader.Read(cvm.FilePath); dataInput.Data = inputFileData; } else { dataInput.Data = cvm.Input; } } } return(!viewModel.IsReference && dataInput.Data == null ? null : dataInput); }
public EntryPage() { SQLiteGeneral sqlDb = new SQLiteGeneral(DependencyService.Get <ISQLiteDb>(), ""); PageService pageService = new PageService(); dataModel = new DataInputViewModel(sqlDb, pageService); InitializeComponent(); dpkTransDate.SetValue(DatePicker.MinimumDateProperty, DateTime.Today.AddMonths(-12)); dpkTransDate.SetValue(DatePicker.MaximumDateProperty, DateTime.Today.AddMonths(12)); dataModel.SelectedDate = DateTime.Today; }
public async System.Threading.Tasks.Task <string> CalCulateAsync([FromBody] DataInputViewModel model) { try { using (var scope = _serviceScopeFactory.CreateScope()) { User user = null; if (!String.IsNullOrEmpty(model.UserName)) { long userId = 0; user = await _userRrepository.GetByName(model.UserName); if (user == null) { user = new User() { Name = model.UserName, CreatedDate = DateTime.Now }; await _userRrepository.Save(user); } userId = user.Id; if (userId > 0) { string Summation = new CalculationService().GetSummation(model); // ""; var calculation = new Calculation() { UserId = userId, Number1 = model.Number1, Number2 = model.Number2, Summation = Summation, CreatedDate = DateTime.Now }; await _calculationRrepository.Save(calculation); return(Summation); } } } } catch (Exception ex) { return(""); //throw; } return(""); }
public void CreateDataInput_InputViewModelGiven_IsReference_ShouldCreateReferencedInput() { const string processName = "testProcess"; var vm = new DataInputViewModel { ProcessName = processName, IsReference = true, ReferenceUrl = "ref uri" }; var input = _requestFactory.CreateDataInput(vm); input.Identifier.Should().Be(processName); input.Data.Should().BeNull(); input.Reference.Href.Should().Be("ref uri"); }
public async Task <IActionResult> Post([FromBody] DataInputViewModel model) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var result = await Task.Run(() => CalCulateAsync(model)); //var result = CalCulateAsync(model); return(Ok(new { summation = result })); } catch (Exception ex) { throw ex; return(Ok());; } }
public DataInputPage(DataInputViewModel data, string type, string mode) { Globals.myAdID = "ca-app-pub-6838059012127071/4824098100"; //create ad control InputModel = new DashboardViewModel(dataInterface, pageService, type, data, mode); if (data.Id == 0) { switch (type) { case "E": Title = "New Expense"; break; case "F": Title = "New Fund"; break; } } else { switch (type) { case "E": Title = "Update Expense"; break; case "F": Title = "Update Fund"; break; } } InitializeComponent(); DateTime oldDate = Convert.ToDateTime("1/1/2020"); dpEntryDate.SetValue(DatePicker.DateProperty, DateTime.Now); dpEntryDate.SetValue(DatePicker.MinimumDateProperty, oldDate); dpEntryDate.SetValue(DatePicker.MaximumDateProperty, DateTime.Now); }
public DataInputViewModel CreateDataInputViewModel(Input input) { if (input == null) { throw new ArgumentNullException(nameof(input)); } var formatVms = input.Data.Formats.GroupBy(f => f.MimeType).Select(f => { var schemas = f.Where(fs => !string.IsNullOrEmpty(fs.Schema)).Select(fs => fs.Schema).ToList(); var encodings = f.Where(fe => !string.IsNullOrEmpty(fe.Encoding)).Select(fe => fe.Encoding).ToList(); var formatVm = new FormatViewModel { MimeType = f.Key, Schemas = new ObservableCollection <string>(schemas), SelectedSchema = schemas.FirstOrDefault(), Encodings = new ObservableCollection <string>(encodings), SelectedEncoding = encodings.FirstOrDefault() }; return(formatVm); }).ToList(); var isOptional = input.MinimumOccurrences == 0; DataInputViewModel vm; if (input.Data is LiteralData ld) { vm = new LiteralInputViewModel(); } else if (input.Data is BoundingBoxData bbd) { vm = new BoundingBoxInputViewModel(_mapService, _context, _dialogService); } else if (input.Data is ComplexData cd) { vm = new ComplexDataViewModel(_dialogService); } else { vm = new DataInputViewModel(); } vm.IsOptional = isOptional; vm.ProcessName = input.Identifier; vm.Formats = new ObservableCollection <FormatViewModel>(formatVms); var defaultFormat = input.Data.Formats.FirstOrDefault(f => f.IsDefault); if (defaultFormat != null) { var selectedVm = formatVms.FirstOrDefault(v => v.MimeType.Equals(defaultFormat.MimeType, StringComparison.InvariantCultureIgnoreCase)); if (selectedVm != null) { selectedVm.SelectedSchema = defaultFormat.Schema; selectedVm.SelectedEncoding = defaultFormat.Encoding; vm.SelectedFormat = selectedVm; } } else { vm.SelectedFormat = vm.Formats.FirstOrDefault(); } return(vm); }
public IActionResult Enter() { DataInputViewModel model = new DataInputViewModel(); return(View(model)); }
public IActionResult Enter(DataInputViewModel model) { //todo add validation on server side return(Content($"This is post method {model.Login}--{model.Password}--{model.Title}")); }