public async Task AppendRecord_ShouldThrow_OnModelWithInvalidDescription() { //arrange var target = new ReportService(_recordRepositoryMock.Object, _reportConverterMock.Object, _recordValidatorMock.Object); var invalidModel = new RecordViewModel { Description = "<script>" }; //act Assert.ThrowsAsync<ArgumentException>(() => target.AppendRecordAsync(invalidModel)); }
public Record ConvertToRecord(RecordViewModel viewModel) { return new Record { Date = viewModel.Date, Title = viewModel.Title, MoneySpent = viewModel.MoneySpent, Description = viewModel.Description, RecordTags = viewModel.Tags.Select(tag => new RecordTag { Tag = ConvertToTag(tag) }).ToList() }; }
public RecordPage(INavigation navigation, IMessageBoxService messageBoxService) { viewModel = new RecordViewModel(navigation, messageBoxService); Resources = new ResourceDictionary { { "TagValidatorFactory", new Func <string, object>((arg) => (BindingContext as RecordViewModel)?.ValidateAndReturn(arg)) } }; Application.Current.Resources.Add(Resources); SearchBarTextChanged += HandleSearchBarTextChanged; SearchBarTextSubmited += HandleSearchBarTextSubmited; InitializeComponent(); BindingContext = viewModel; }
public ActionResult Create(RecordViewModel record) { if (ModelState.IsValid) { var recordDataModel = new Record { Id = Guid.NewGuid().ToString(), Author = HttpContext.User.Identity.Name, CreationDate = DateTime.Now, TextBody = record.TextBody, RecordTypeId = record.RecordTypeId }; _provider.AddRecord(recordDataModel); return(RedirectToAction("List")); } else { return(View(record)); } }
public async Task <IActionResult> EditRecord(RecordViewModel model, int?id) { if (ModelState.IsValid) { if (id == null) { return(RedirectToAction("Students", new Dictionary <string, string> { { "id", id?.ToString() } })); } Record record = await db.Records.FirstOrDefaultAsync(r => r.RecordId == id); if (record == null) { return(RedirectToAction("StudentSubjects", new Dictionary <string, string> { { "stud", record.StudentAccountId.ToString() } })); } //record.SubjectId = model.SubjectId; record.DateEnd = model.DateEnd; db.Records.Update(record); await db.SaveChangesAsync(); return(RedirectToAction("StudentSubjects", new Dictionary <string, string> { { "stud", record.StudentAccountId.ToString() } })); } return(View("Create/Record", model)); }
public ActionResult Edit(RecordViewModel record) { if (ModelState.IsValid) { int userId = users.GetUserIdByName(User.Identity.Name); service.UpdateRecord( new RecordDTO() { Id = record.Id, UserId = userId, ProjectId = record.ProjectId, TaskId = record.TaskId, Hours = record.Hours, Note = record.Note, RecordDateTime = DateTime.Parse(record.Date + ',' + record.Time, new CultureInfo("en", false)) } ); return(RedirectToAction(nameof(UserList))); } return(View(record)); }
public ActionResult Create(RecordViewModel recordViewModel) { if (ModelState.IsValid) { Record record = new Record() { Id = recordViewModel.Id, ClientId = recordViewModel.ClientId, ProcedureId = recordViewModel.ProcedureId, DayRecord = recordViewModel.DayRecord, TimeRecord = recordViewModel.TimeRecord, Comment = recordViewModel.Comment, Client = recordViewModel.Client, Procedure = recordViewModel.Procedure }; db.Records.Add(record); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(recordViewModel)); }
public async Task <ActionResult> Create(RecordViewModel recordViewModel) { if (ModelState.IsValid) { await _recordService.Add(recordViewModel.MapToDto()); return(RedirectToAction("Index")); } var clients = _clientService.GetItems(); ViewBag.ClientId = new SelectList(clients, "Id", "Name", recordViewModel.ClientId); var procedures = _procedureService.GetItems(); ViewBag.ProcedureId = new SelectList(procedures, "Id", "Name", recordViewModel.ProcedureId); var products = _productService.GetItems(); ViewBag.ProductId = new SelectList(products, "Id", "Name", recordViewModel.ProductId); return(View(recordViewModel)); }
public async Task <ActionResult <Record> > PostRecord(RecordViewModel recordViewModel) { var record = new Record() { CompulsionId = recordViewModel.CompulsionId, PatientActionId = recordViewModel.PatientActionId, TimeStamp = DateTime.Now }; try { var userId = HttpContext.GetUserId(); record.ApplicationUserId = userId; _context.Record.Add(record); await _context.SaveChangesAsync(); } catch (Exception ex) { //throw new EntryPointNotFoundException(); } return(CreatedAtAction("GetRecord", new { id = record.RecordId }, record)); }
public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var record = await _context.Records.FindAsync(id); if (record == null) { return(NotFound()); } var recordViewModel = new RecordViewModel(); recordViewModel.Suppliers = await(from supplier in _context.Suppliers select supplier).ToListAsync(); recordViewModel.Record = record; ViewData["SuplierId"] = new SelectList(_context.Suppliers, "SupplierId", "Name", record.SuplierId); return(View(recordViewModel)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,ListCitiesIds,Annotation,Text")] RecordViewModel model) { if (id != model.Id || await _vacancy.FindByIdAsync(id) == null) { return(BadRequest()); } model.CitiesForSelection = _city.SelectListCities(await _city.GetRepresentationCities().ToListAsync()); if (!ModelState.IsValid) { return(View(model)); } Vacancy vacancy = new Vacancy { Id = model.Id, Name = model.Name, LatinName = model.LatinName, Annotation = model.Annotation, Text = model.Text, }; var citiesIds = new List <int>(); citiesIds.AddRange(model.ListCitiesIds); try { await _vacancy.SaveAsync(vacancy, citiesIds); } catch (DbUpdateException) { ModelState.AddModelError(string.Empty, "Error of saving data"); return(View(model)); } return(RedirectToAction(nameof(Index))); }
public async Task <ApiResult> Post([FromBody] RecordViewModel record) { if (record == null) { return(new ApiResult(ReturnCode.ArgsError)); } try { if (string.IsNullOrEmpty(record._id) && record.State == 1) { record.CreateTime = DateTime.Now; await _recordService.InsertOneAsync(record); } else if (!string.IsNullOrEmpty(record._id) && record.State == 2) { await _recordService.UpdateOneAsync(record, "State"); } } catch (Exception) { return(new ApiResult(ReturnCode.GeneralError)); } return(new ApiResult(ReturnCode.Success)); }
public void UpdateRecordData(RecordViewModel record) { _storageDb.UpdateRecordData(record); }
public IActionResult Ok(RecordViewModel model) { string uniqueFileName = null; string filePath = null; if (model.RecordFile != null) { string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "records"); uniqueFileName = Guid.NewGuid().ToString() + "_" + model.RecordFile.FileName; filePath = Path.Combine(uploadsFolder, uniqueFileName); model.RecordFile.CopyTo(new FileStream(filePath, FileMode.Create)); } //execute .py // create process info var psi = new ProcessStartInfo(); psi.FileName = @"C:\Users\Professional\AppData\Local\Programs\Python\Python36\python.exe"; //provide script and argument var script = @"C:\Users\Professional\Desktop\1studing\CourseWork3\course_work_app\Course_work\cnn_code_4_classes\predicting_4.py"; var arg = model.RecordFile.FileName.Split(".")[0]; psi.Arguments = $"{script} {arg}"; //process configuration psi.UseShellExecute = false; psi.CreateNoWindow = true; psi.RedirectStandardOutput = true; psi.RedirectStandardError = true; //execute process and get output var errors = ""; string results = ""; using (var process = Process.Start(psi)) { errors = process.StandardError.ReadToEnd(); results = process.StandardOutput.ReadToEnd(); //Console.WriteLine(results); } string data = null; using (var reader = new StreamReader(model.RecordFile.OpenReadStream())) { while (reader.Peek() >= 0) { data += reader.ReadLine(); } //data = reader.ReadToEnd(); } List <int> listValues = new List <int>(); string[] numbers = Regex.Split(data, @"\D+"); foreach (string value in numbers) { if (!string.IsNullOrEmpty(value)) { int i = int.Parse(value); listValues.Add(i); } } ViewBag.VALUES = listValues; ViewBag.RESULT = model.RecordFile.FileName; string[] allResults = results.Split(' '); string resN = allResults[2] + "%"; string resRBBB = allResults[4] + "%"; string resB = allResults[6] + "%"; string resAFIB = allResults[8] + "%"; ViewBag.N = resN; ViewBag.RBBB = resRBBB; ViewBag.B = resB; ViewBag.AFIB = resAFIB; string lineFromFile = ""; FileStream fileStream = new FileStream(@"C:\Users\Professional\Desktop\1studing\CourseWork3\course_work_app\Course_work\cnn_code_4_classes\EcgApp\EcgApp\App_Data\sectorsFile.txt", FileMode.Open); using (StreamReader reader = new StreamReader(fileStream)) { lineFromFile = reader.ReadLine(); } string[] allSectors = lineFromFile.Split(';'); List <string> listN = new List <string>(); List <string> listRBBB = new List <string>(); List <string> listB = new List <string>(); List <string> listAFIB = new List <string>(); for (int i = 0; i < allSectors.Length - 1; i++) { string[] val = allSectors[i].Split(':'); if (val[2] == "0") { listN.Add(val[0] + ", " + val[1] + ";"); } else if (val[2] == "1") { listRBBB.Add(val[0] + ", " + val[1] + ";"); } else if (val[2] == "2") { listB.Add(val[0] + ", " + val[1] + ";"); } else if (val[2] == "3") { listAFIB.Add(val[0] + ", " + val[1] + ";"); } } model.TypeN = listN; model.TypeRBBB = listRBBB; model.TypeB = listB; model.TypeAFIB = listAFIB; ViewBag.listN = listN; ViewBag.listRBBB = listRBBB; ViewBag.listB = listB; ViewBag.listAFIB = listAFIB; return(View()); }
public void DeleteRecord(RecordViewModel record) { _storageDb.DeleteRecord(record); }
public RecordView() { InitializeComponent(); recordViewModel = new RecordViewModel(); this.DataContext = recordViewModel; }
public RecordPage(Routine routine) { BindingContext = viewModel = new RecordViewModel(Navigation, routine); InitializeComponent(); }
public void SetUp() { _id = "someId"; _name = "someName"; _tagString = "tag1;tag2"; _passwordRecords = new List <PasswordRecord>() { new PasswordRecord() { Name = "Name1", Value = "Value1" }, new PasswordRecord() { Name = "Name2", Value = "Value2" }, new PasswordRecord() { Name = "Name3", Value = "Value3" }, }; _fileRecords = new List <FileRecord>() { new FileRecord() { Name = "Name1", Extention = "pdf", Description = "Description1", AssociatedRecordId = _id, FileId = "F1" }, new FileRecord() { Name = "Name2", Extention = "txt", Description = "Description2", AssociatedRecordId = _id, FileId = "F2" }, new FileRecord() { Name = "Name3", Extention = "xlsx", Description = "Description3", AssociatedRecordId = _id, FileId = "F3" }, }; var record = new Record { Header = new RecordHeader(), FileRecords = new List <FileRecord>(), PasswordRecords = new List <PasswordRecord>() }; record.Header.Id = _id; record.Header.Name = _name; record.Header.Tags = _tagString; record.PasswordRecords.AddRange(_passwordRecords); record.FileRecords.AddRange(_fileRecords); _fileSafe = Substitute.For <IFileSafe>(); _fileIdGenerator = Substitute.For <IFileIdGenerator>(); _recordViewModel = new RecordViewModel(record, _fileSafe, _fileIdGenerator); _recordModificationStatus = false; _recordViewModel.RecordChanged += () => { _recordModificationStatus = _recordViewModel.IsRecordModified; }; }
public ActionResult AddRecord(RecordViewModel model) { return(View()); }
public void SaveRecord(RecordViewModel _recordViewModel) { if (_recordViewModel.Receiver.Id == 0) { this._context.Receivers.Add(_recordViewModel.Receiver); this._context.VendorLists.Add(_recordViewModel.Receiver.VendorList); this._context.FoodConditions.Add(_recordViewModel.Receiver.FoodCondition); this._context.Details.Add(_recordViewModel.Receiver.FoodCondition.Detail); if (string.IsNullOrWhiteSpace(_recordViewModel.Receiver.Signature.ManagerSignature)) { this._context.Signatures.Add(_recordViewModel.Receiver.Signature); } else { var getBase64Signature = _recordViewModel.Receiver.Signature.ManagerSignature.Split(",")[1]; _recordViewModel.Receiver.Signature.ManagerSignature = getBase64Signature; this._context.Signatures.Add(_recordViewModel.Receiver.Signature); } } else { RecordViewModel _recordEntry = new RecordViewModel(); _recordEntry.Receiver = this._context.Receivers .Include(vl => vl.VendorList) //.Include(fc => fc.FoodCondition) .Include(pc1 => pc1.FoodCondition.PackageCondition) .Include(pc2 => pc2.FoodCondition.ProductCondition) .Include(pt1 => pt1.FoodCondition.PackageTemperature) .Include(pt2 => pt2.FoodCondition.ProductTemperature) .Include(d => d.FoodCondition.Detail) .Include(s => s.Signature) .FirstOrDefault(item => item.Id == _recordViewModel.Receiver.Id); _recordEntry.VendorList = this._context.VendorLists .FirstOrDefault(item => item.Id == _recordEntry.Receiver.VendorList.Id); _recordEntry.FoodCondition = this._context.FoodConditions .FirstOrDefault(item => item.Id == _recordEntry.Receiver.FoodCondition.Id); int _checkStat = 0; if (_recordEntry.Receiver.Signature != null) { _recordEntry.Signature = this._context.Signatures .FirstOrDefault(item => item.Id == _recordEntry.Receiver.Signature.Id); _checkStat = 1; } if (_recordEntry != null) { _recordEntry.Receiver.UnitName = _recordViewModel.Receiver.UnitName; _recordEntry.Receiver.UnitNumber = _recordViewModel.Receiver.UnitNumber; _recordEntry.Receiver.FirstName = _recordViewModel.Receiver.FirstName; _recordEntry.Receiver.LastName = _recordViewModel.Receiver.LastName; _recordEntry.Receiver.Day = _recordViewModel.Receiver.Day; _recordEntry.Receiver.DeliveryDate = _recordViewModel.Receiver.DeliveryDate; _recordEntry.Receiver.DeliveryTime = _recordViewModel.Receiver.DeliveryTime; _recordEntry.Receiver.RecordStatus = _recordViewModel.Receiver.RecordStatus; _recordEntry.VendorList.Vendors = _recordViewModel.Receiver.VendorList.Vendors; _recordEntry.FoodCondition.PackageCondition.Acceptable = _recordViewModel.Receiver.FoodCondition.PackageCondition.Acceptable; _recordEntry.FoodCondition.PackageCondition.Unacceptable = _recordViewModel.Receiver.FoodCondition.PackageCondition.Unacceptable; _recordEntry.FoodCondition.ProductCondition.Acceptable = _recordViewModel.Receiver.FoodCondition.ProductCondition.Acceptable; _recordEntry.FoodCondition.ProductCondition.Unacceptable = _recordViewModel.Receiver.FoodCondition.ProductCondition.Unacceptable; _recordEntry.FoodCondition.PackageTemperature.Acceptable = _recordViewModel.Receiver.FoodCondition.PackageTemperature.Acceptable; _recordEntry.FoodCondition.PackageTemperature.Unacceptable = _recordViewModel.Receiver.FoodCondition.PackageTemperature.Unacceptable; _recordEntry.FoodCondition.ProductTemperature.Acceptable = _recordViewModel.Receiver.FoodCondition.ProductTemperature.Acceptable; _recordEntry.FoodCondition.ProductTemperature.Unacceptable = _recordViewModel.Receiver.FoodCondition.ProductTemperature.Unacceptable; _recordEntry.FoodCondition.Detail.AdditionalDetail = _recordViewModel.Receiver.FoodCondition.Detail.AdditionalDetail; _recordEntry.FoodCondition.Detail.CorrectiveAction = _recordViewModel.Receiver.FoodCondition.Detail.CorrectiveAction; if (_checkStat == 1) { _recordEntry.Signature.ManagerSignature = _recordViewModel.Receiver.Signature.ManagerSignature; _recordEntry.Signature.DateVerified = _recordViewModel.Receiver.Signature.DateVerified; } } } this._context.SaveChanges(); }
public async Task <IActionResult> EditRecord(RecordViewModel model) { MessageTitle = "Failed"; MessageIcon = "error"; try { if (ModelState.IsValid) { var record = _context.Records.Find(model.ID); if (record != null) { record.TTL = model.TTL; record.Name = model.Name; record.Content = model.Content; record.Type = model.Type.ToString(); Logger.Log(Logger.LogType.UPDATE, JsonConvert.SerializeObject(model), "Records", model.ID); await _context.SaveChangesAsync(); MessageTitle = "Done"; MessageIcon = "success"; Message = "Record updated successfully."; } else { Message = @"The requested record not found"; MessageTitle = "Failed"; MessageIcon = "error"; } } else { string errors = string.Empty; foreach (var mv in ModelState.Values) { foreach (var error in mv.Errors) { errors += error.ErrorMessage + "<br>"; } } Message = @$ "Invalid Data, {ModelState.ErrorCount} errors.<br>Errors:{errors}"; MessageTitle = "Failed"; MessageIcon = "error"; } } catch (Exception ex) { Message = $@"{ex.Message}"; if (ex.InnerException != null) { Message += $@"<br>{ex.InnerException.Message}"; } MessageTitle = "Failed"; MessageIcon = "error"; } return(new JsonResult(new Dictionary <string, string>() { { "Message", Message }, { "Title", MessageTitle }, { "Icon", MessageIcon } }) { StatusCode = (MessageIcon == "error") ? 500 : 200 }); }
public RecordEdition() { InitializeComponent(); DataContext = new RecordViewModel(this); }
public ActionResult Review(RecordViewModel viewrecord) { if (viewrecord != null) { Record record = new Record(); record.PaperNumber = viewrecord.PaperNumber.Trim(); record.CountryCountryID = viewrecord.CountryCountryID; record.Comments = viewrecord.Comments; record.hadarrivechecklist = viewrecord.hadarrivechecklist; if (record.hadarrivechecklist == "Yes" | record.CategoryCategoryID == 1) { record.AuthorCompliance = "N/A"; } string CountryName = _db.Countries.Where(c => c.CountryID == record.CountryCountryID).Select(c => c.CountryName).First(); if (ModelState.IsValid) { record.CategoryCategoryID = CategoryRandom(CountryName); record.EntryUser = User.Identity.Name; record.RandomizationTime = DateTime.Now; record.RandomizationTimeUTC = DateTime.UtcNow; _db.Records.Add(record); _db.SaveChanges(); //if (record.CategoryCategoryID == 1) //{ // ViewBag.Action = "NO"; //} //else //{ // if (record.hadarrivechecklist == "Yes") { ViewBag.Action = "NO"; } // else { ViewBag.Action = "Please request ARRIVE checklist"; } //} ViewBag.Action = (record.CategoryCategoryID == 1) ? "Do NOT request ARRIVE checklist" : ((record.hadarrivechecklist == "Yes") ? "Do NOT request ARRIVE checklist" : "Request ARRIVE checklist"); var message = "Thank you for randomizing paper for IICURas.<br> <br> The following details have been recorded: <br/> <br/>Paper Number: " + viewrecord.PaperNumber.ToString() + "<br /> Country of Corresponding Author: " + viewrecord.CountryCountryName.ToString() + "<br / > Manuscript has already provided ARRIVE checklist: " + viewrecord.hadarrivechecklist.ToString() + "<br />Action: " + ViewBag.Action + "<br/ > <br/> IICRUas Team<br/>" + DateTime.Now.Date; sendemail(User.Identity.Name, message); return(RedirectToAction("Details", new { id = record.RecordID })); } return(View(viewrecord)); } else { return(RedirectToAction("Create")); } }
public async Task Update(RecordViewModel recordVM) { var record = _mapper.Map <Record>(recordVM); await _recordService.Update(record); }
public void OnRecordSelected(object sender, RecordViewModel e) { ViewNewRecord(e); }
// GET: Clients/Create public ActionResult Create() { RecordViewModel viewModel = new RecordViewModel(); return(View(viewModel)); }
private void ViewMethodComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { var SelectedItem = ViewMethodComboBox.SelectedItem as ViewMethodViewModel; if (SelectedItem == null) { return; } if (SelectedItem.Id == 0) { // Daily view, switched from Monthly view // Use backup records var viewModel = (RecordManagerViewModel)DataContext; var records = viewModel.BackupRecords; viewModel.Records = new ObservableCollection <RecordViewModel>(records); DeleteButton.Visibility = Visibility.Visible; } else { // Monthly view // Hide the analysis panel AnalyzerPanel.Visibility = Visibility.Collapsed; // Process current data to switch view var viewModel = (RecordManagerViewModel)DataContext; var records = viewModel.BackupRecords; // Group records, based on months var groupedData = new Dictionary <string, System.Collections.Generic.List <RecordViewModel> >(); foreach (var record in records) { var dateTime = DateTime.Parse(record.DateTime); var monthTime = dateTime.ToString("yyyy-MM"); var newKey = record.ReservoirId.ToString() + "/" + monthTime; if (groupedData.ContainsKey(newKey)) { // Existing // Add the record var data = groupedData[newKey]; data.Add(record); groupedData[newKey] = data; } else { // New var data = new List <RecordViewModel>(); data.Add(record); groupedData[newKey] = data; } } // Process grouped data var processedData = new ObservableCollection <RecordViewModel>(); var keys = groupedData.Keys; foreach (var key in keys) { var monthData = groupedData[key]; if (monthData.Count == 1) { // Only single record for a month // Add it directly. Just change DateTime. // No need to do the analysis again var keyParts = key.Split('/'); var monthRecord = new RecordViewModel { DateTime = keyParts[1], Id = -1, ReservoirId = monthData[0].ReservoirId, ReservoirName = monthData[0].ReservoirName, Temperature = monthData[0].Temperature, TemperatureRange = monthData[0].TemperatureRange, PH = monthData[0].PH, DO = monthData[0].DO, BOD5 = monthData[0].BOD5, COD = monthData[0].COD, NH4N = monthData[0].NH4N, NO2N = monthData[0].NO2N, NO3N = monthData[0].NO3N, SS = monthData[0].SS, CL = monthData[0].CL, CB = monthData[0].CB, Overall = monthData[0].Overall, Level = monthData[0].Level, }; processedData.Add(monthRecord); } else { var keyParts = key.Split('/'); string DateTime = keyParts[1]; int ReservoirId = monthData[0].ReservoirId; string ReservoirName = monthData[0].ReservoirName; double Temperature = monthData[0].Temperature; double PH = double.Parse(monthData[0].PH); double DO = double.Parse(monthData[0].DO); double BOD5 = double.Parse(monthData[0].BOD5); double COD = double.Parse(monthData[0].COD); double NH4N = double.Parse(monthData[0].NH4N); double NO2N = double.Parse(monthData[0].NO2N); double NO3N = double.Parse(monthData[0].NO3N); double SS = double.Parse(monthData[0].SS); double CL = double.Parse(monthData[0].CL); double CB = double.Parse(monthData[0].CB); for (int i = 1; i < monthData.Count; i++) { if (monthData[i].Temperature == Temperature) { // Records in the same month should have the same temperature range. PH += double.Parse(monthData[i].PH); DO += double.Parse(monthData[i].DO); BOD5 += double.Parse(monthData[i].BOD5); COD += double.Parse(monthData[i].COD); NH4N += double.Parse(monthData[i].NH4N); NO2N += double.Parse(monthData[i].NO2N); NO3N += double.Parse(monthData[i].NO3N); SS += double.Parse(monthData[i].SS); CL += double.Parse(monthData[i].CL); CB += double.Parse(monthData[i].CB); } else { // Temperature range is different. // Can't analyze the data. viewModel.ShowMessageCommand.Execute("There must be some error in the data. Please inspect it and try again."); return; } } PH = PH / monthData.Count; DO = DO / monthData.Count; BOD5 = BOD5 / monthData.Count; COD = COD / monthData.Count; NH4N = NH4N / monthData.Count; NO2N = NO2N / monthData.Count; NO3N = NO3N / monthData.Count; SS = SS / monthData.Count; CL = CL / monthData.Count; CB = CB / monthData.Count; var Is = AnalysisEngine.CalculateSimpleIndices(Temperature, PH, DO, BOD5, COD, NH4N, NO2N, NO3N, SS, CL, CB); var Ws = AnalysisEngine.GetWeightCoefficients(Temperature, Is); double OverallIndex = AnalysisEngine.CalculateOverallIndex(Is, Ws); int Level = AnalysisEngine.GetLevel(Temperature, OverallIndex); var monthRecord = new RecordExtended { Id = -1, Temperature = Temperature, PH = PH, DO = DO, BOD5 = BOD5, COD = COD, NH4N = NH4N, NO2N = NO2N, NO3N = NO3N, SS = SS, CL = CL, CB = CB, Overall = OverallIndex, Level = Level, ReservoirId = ReservoirId, ReservoirName = ReservoirName, DateTime = DateTime }; processedData.Add(new RecordViewModel(monthRecord)); } } viewModel.Records = processedData; DeleteButton.Visibility = Visibility.Collapsed; } }
public RecordPage() { _recordViewModel = ViewModelLocator.RecordViewModel; InitializeComponent(); }
public RecordWindow() { InitializeComponent(); StateChanged += CustomizedWindow.WindowStyle.Window_StateChanged; DataContext = new RecordViewModel(); }
public async Task <int> UpdateOneAsync(RecordViewModel viewModel, params string[] fields) { var model = _mapper.Map <Record>(viewModel); return(await _recordRepository.UpdateOneAsync(model, fields)); }
public async Task <IActionResult> AddRecord(RecordViewModel record) { try { if (ModelState.IsValid) { var member = new Record() { Name = record.Name + $".{_context.Domains.Find(record.DomainID).Name}", Type = record.Type.ToString(), Content = record.Content, Domain_ID = record.DomainID, TTL = (record.TTL >= 0) ? record.TTL : 86400, Prio = 0, Change_Date = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, Auth = 1 }; _context.Add(member); Logger.Log(Logger.LogType.INSERT, JsonConvert.SerializeObject(member), "Records", member.ID); await _context.SaveChangesAsync(); MessageTitle = "Done"; Message = "Record added successfully."; MessageIcon = "success"; } else { string errors = string.Empty; foreach (var mv in ModelState.Values) { foreach (var error in mv.Errors) { errors += error.ErrorMessage + "<br>"; } } Message = @$ "Invalid Data, {ModelState.ErrorCount} errors.<br>Errors:{errors}"; MessageTitle = "Failed"; MessageIcon = "error"; } } catch (Exception ex) { Message = $@"{ex.Message}"; if (ex.InnerException != null) { Message += $@"<br>{ex.InnerException.Message}"; } MessageTitle = "Failed"; MessageIcon = "error"; } return(new JsonResult(new Dictionary <string, string>() { { "Message", Message }, { "Title", MessageTitle }, { "Icon", MessageIcon } }) { StatusCode = (MessageIcon == "error") ? 500 : 200 }); }
public DeleteRecordCommand(ICollection <RecordViewModel> collection, RecordViewModel record) { this.collection = collection; this.record = record; }