public IActionResult Edit(RecordDTO model, string ParkTipi, string Bolge, string Altbolge, string Ilce) { RecordSelected record = _parkcontext.RecordSelects.FirstOrDefault(q => q.ID == model._id); record.ParkAdi = model.ParkAdi; record.LokasyonAdi = model.LokasyonAdi; record.ParkKapasitesi = model.ParkKapasitesi; record.CalismaSaatleri = model.CalismaSaatleri; record.Aylik_Abonelik_Ucreti = model.Aylik_Abonelik_Ucreti; record.Ucretsiz_Parklanma_Suresi_dakika = model.Ucretsiz_Parklanma_Suresi_dakika; record.Tarifesi = model.Tarifesi; record.Adres = model.Adres; record.ParkTipi = ParkTipi; record.Bolge = Bolge; record.AltBolge = Altbolge; record.Ilce = Ilce; _parkcontext.SaveChanges(); return(Redirect("/RecordSelected/selectedrecords")); }
// GET: Record/Edit/{id} public ActionResult Edit(int id) { RecordDTO record = service.GetRecord(id); int userId = users.GetUserIdByName(User.Identity.Name); return(View( new RecordViewModel() { Id = record.Id, UserId = userId, TaskId = record.TaskId, Hours = record.Hours, Note = record.Note, TaskName = projects.GetTask(record.TaskId).Name, ProjectName = projects.GetProject(record.ProjectId).Name, RecordDateTime = record.RecordDateTime, Date = record.RecordDateTime.Date.ToShortDateString(), Time = record.RecordDateTime.TimeOfDay.ToString(), ProjectId = record.ProjectId } )); }
public async Task <Record> UpdateRecord(RecordDTO recordDto, int boardId) { var srcBoard = await _db.Records .Where(r => r.Id == recordDto.RecordId && r.BoardId == boardId) .FirstOrDefaultAsync(); if (recordDto.Name != null) { srcBoard.Name = recordDto.Name; } if (recordDto.Description != null) { srcBoard.Description = recordDto.Description; } srcBoard.EndDate = srcBoard.EndDate; await _db.SaveChangesAsync(); return(srcBoard); }
public void RegisterNewRecordPost_WithValidModel_Returns_CreatedAtActionResult() { // Arrange var recordServiceMock = new Mock <IRecordService>(); recordServiceMock.Setup(service => service .RegisterNewRecordAsync(It.IsAny <RecordDTO>())) .Returns(Task.FromResult((1, true))); var loggerMock = new Mock <ILogger <RecordsController> >(); var controller = new RecordsController(recordServiceMock.Object, loggerMock.Object); var recordDTO = new RecordDTO(); // Act var result = controller.RegisterNewRecord(recordDTO).GetAwaiter().GetResult(); // Assert var createdAtActionResult = Assert.IsType <CreatedAtActionResult>(result); Assert.IsAssignableFrom <RecordDTO>(createdAtActionResult.Value); }
public IActionResult Put(int id, [FromBody] RecordDTO dto) { if (!ModelState.IsValid) { return(BadRequest()); } var record = _recoredRepo.Get(id); if (record == null) { return(NotFound()); } _mapper.Map(dto, record); // (from, to) if (_recoredRepo.SaveAll()) { return(Ok()); } return(BadRequest($"Updating record {id} failed on save")); }
/// <inheritdoc/> public async Task <bool> UpdateRecordAsync(RecordDTO recordDTO) { var record = await _sensorContext.Records.FirstOrDefaultAsync(r => r.Id == recordDTO.Id); if (record == null) { return(false); } if (recordDTO.Value == null) { _logger.LogError(RecordsConstants.EMPTY_RECORD_VALUE); return(false); } record.Value = recordDTO.Value; record.Date = recordDTO.Date; record.IsDeleted = recordDTO.IsDeleted; if (record.SensorDevice.Serial != recordDTO.SensorDeviceSerial) { var newSensorDevice = await _sensorContext.Sensors.FirstOrDefaultAsync(s => s.Serial == recordDTO.SensorDeviceSerial); if (newSensorDevice == null) { _logger.LogError(SensorsConstants.UNKNOWN_SENSOR_SERIAL); return(false); } else { record.SensorDeviceId = newSensorDevice.Id; record.SensorDevice = newSensorDevice; } } _sensorContext.Update(record); await _sensorContext.SaveChangesAsync(new CancellationToken()); return(true); }
public void DeleteRecord_WithInvalidModelId_Returns_NotFoundResult() { // Arrange var recordServiceMock = new Mock <IRecordService>(); recordServiceMock.Setup(service => service .DeleteRecordByIdAsync(It.IsAny <int>())) .Returns(Task.FromResult(false)); var loggerMock = new Mock <ILogger <RecordsController> >(); var controller = new RecordsController(recordServiceMock.Object, loggerMock.Object); var recordDTO = new RecordDTO(); var id = 1; // Act var result = controller.DeleteRecord(id).GetAwaiter().GetResult(); // Assert var notFoundObjectResult = Assert.IsType <NotFoundObjectResult>(result); Assert.IsAssignableFrom <int>(notFoundObjectResult.Value); }
public async Task <ActionResult <ResponseDTO> > PutRecord(long id, RecordDTO recordDTO) { var record = await _context.Records.FindAsync(id); record.Type = recordDTO.Type == null ? record.Type : recordDTO.Type; record.Description = recordDTO.Description == null ? record.Description : recordDTO.Description; record.ProblemType = recordDTO.ProblemType == null ? record.ProblemType : recordDTO.ProblemType; record.IsTraining = recordDTO.IsTraining == null ? record.IsTraining : recordDTO.IsTraining; record.Title = recordDTO.Title == null ? record.Title : recordDTO.Title; record.IdSupervisedArea = recordDTO.IdSupervisedArea == null ? record.IdSupervisedArea : recordDTO.IdSupervisedArea; record.IdDrone = recordDTO.IdDrone == null ? record.IdDrone : recordDTO.IdDrone; record.IdCampaign = recordDTO.IdCampaign == null ? record.IdCampaign : recordDTO.IdCampaign; record.IdFlightPath = recordDTO.IdFlightPath == null ? record.IdFlightPath : recordDTO.IdFlightPath; record.Longitude = recordDTO.Longitude == null ? record.Longitude : recordDTO.Longitude; record.Latitude = recordDTO.Latitude == null ? record.Latitude : recordDTO.Latitude; record.MonitoredObjectId = recordDTO.MonitoredObjectId == null ? record.MonitoredObjectId : recordDTO.MonitoredObjectId; record.MetaData = recordDTO.MetaData == null ? record.MetaData : recordDTO.MetaData; _context.Entry(record).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RecordExists(id)) { return(new ResponseDTO("Không tồn tại ", 404)); } else { throw; } } return(new ResponseDTO("Update thành công", 200, record)); }
public void UpdateRecord_WithNonexistingId_Returns_NotFoundResult() { // Arrange var recordServiceMock = new Mock <IRecordService>(); recordServiceMock.Setup(service => service .GetRecordByIdAsync(It.IsAny <int>())) .Returns(Task.FromResult(GetNullRecord())); var loggerMock = new Mock <ILogger <RecordsController> >(); var controller = new RecordsController(recordServiceMock.Object, loggerMock.Object); var recordDTO = new RecordDTO { Id = 2 }; // Act var result = controller.UpdateRecord(recordDTO).GetAwaiter().GetResult(); // Assert var notFoundObjectResult = Assert.IsType <NotFoundObjectResult>(result); Assert.IsAssignableFrom <int>(notFoundObjectResult.Value); }
public IActionResult Edit(int id) { Record record = _parkcontext.Records.FirstOrDefault(x => x.ID == id); RecordDTO model = new RecordDTO(); model._id = record.ID; model.ParkID = record.ParkID; model.ParkAdi = record.ParkAdi; model.LokasyonAdi = record.LokasyonAdi; model.LokasyonKodu = record.LokasyonKodu; model.ParkTipi = record.ParkTipi; model.ParkKapasitesi = record.ParkKapasitesi; model.CalismaSaatleri = record.CalismaSaatleri; model.Bolge = record.Bolge; model.AltBolge = record.AltBolge; model.Ilce = record.Ilce; model.Adres = record.Adres; model.Enlem_Boylam = record.Enlem_Boylam; model.Polygon_Verisi = record.Polygon_Verisi; model.Boylam = record.Boylam; model.Enlem = record.Enlem; model.Aylik_Abonelik_Ucreti = record.Aylik_Abonelik_Ucreti; model.Ucretsiz_Parklanma_Suresi_dakika = record.Ucretsiz_Parklanma_Suresi_dakika; model.Tarifesi = record.Tarifesi; model.Park_Et_Devam_Et_Noktasi = record.Park_Et_Devam_Et_Noktasi; List <Record> records = _parkcontext.Records.ToList(); List <AltBolgeDTO> altBolgeDTOs = new List <AltBolgeDTO>(); foreach (var item in records) { var recordControl = altBolgeDTOs.FirstOrDefault(x => x.AltBolgeAd == item.AltBolge); if (recordControl == null) { AltBolgeDTO modelaltbolge = new AltBolgeDTO(); modelaltbolge.AltBolgeAd = item.AltBolge; altBolgeDTOs.Add(modelaltbolge); } } model.AltBolgeDTOs = altBolgeDTOs; List <IlceDTO> IlceDTOs = new List <IlceDTO>(); foreach (var item in records) { var recordControl = IlceDTOs.FirstOrDefault(x => x.IlceAd == item.Ilce); if (recordControl == null) { IlceDTO modelılce = new IlceDTO(); modelılce.IlceAd = item.Ilce; IlceDTOs.Add(modelılce); } } model.IlceDTOs = IlceDTOs; List <ParkTipiDTO> parkTipiDTOs = new List <ParkTipiDTO>(); foreach (var item in records) { var recordControl = parkTipiDTOs.FirstOrDefault(x => x.ParkTipiAd == item.ParkTipi); if (recordControl == null) { ParkTipiDTO modelparktipi = new ParkTipiDTO(); modelparktipi.ParkTipiAd = item.ParkTipi; parkTipiDTOs.Add(modelparktipi); } } model.ParkTipiDTOs = parkTipiDTOs; return(View(model)); }
public async Task <ActionResult> UpdateRecord([FromBody] RecordDTO recordDto, int boardId) { var updatedBoard = await _recordRepository.UpdateRecord(recordDto, boardId); return(Ok(updatedBoard)); }
public async Task Post([FromBody] RecordDTO record) { record.UserId = RequestContext.Principal.Identity.GetUserId <int>(); await _recordService.Insert(record); }
/// <summary> /// Handler for the CodeActivity17 Activity’s ExecuteEvent event. /// </summary> /// <param name=\"sender\">The activity object that raised the ExecuteEvent event.</param> /// <param name=\"args\">The event arguments passed to the activity.</param> /// Use this.CodeActivity17 to access the CodeActivity17 Activity's context, including input and output properties. public void CodeActivity17_OnExecuteEvent(object sender, STActivityBaseEventArgs args) { if (SwitchEnvironment14.IsLoadTestEnabled != "true") { int docArrayElementCount = 0; checkArgs = new CheckpointEventArgs(this.CodeActivity17); //Get the response XMLString = this.RESTActivityV24.ResponseBody; //Create Deserialize object DeserializedXMLproductResponse = XMLString.DeserializeFromXMLInput <ProductResponse>(); //Customize the SQL Query for count customisedCountSqlQuery = "Select count(*) from (" + this.CodeActivity7.Output.Out_SQLParameter + ")"; //Customize the SQL Query customisedSqlQuery = this.CodeActivity7.Output.Out_SQLParameter; //opening the DB conenction OpenDBConnection(this.CodeActivity7.Input.DBConnectionString); //Get the record from the database record = GetRecord(customisedCountSqlQuery, customisedSqlQuery, this.CodeActivity17); //verify database records count checkArgs.Checkpoint.Assert.Equals("", DeserializedXMLproductResponse.RowsTotal.ToString(), record.RecordsCount.ToString(), "Records count"); //Verify product data foreach (Product doc_ProductNote in DeserializedXMLproductResponse.Products.Product) { //isRecordAvailable = false; foreach (Product2DTO recordNote in record.Product) { //Compare product Primary key if (doc_ProductNote.ProductId.ToString() == recordNote.productId) { string altCodes = sortString(recordNote.altCodes); //Verify productId AssertIfNotNull(checkArgs, doc_ProductNote.ProductId, recordNote.productId, "Product V2 productId: " + docArrayElementCount); //Verify productDesc AssertIfNotNull(checkArgs, doc_ProductNote.Description, recordNote.description, "Product V2 prodDesc: " + docArrayElementCount); //Verify discGroupId AssertIfNotNull(checkArgs, doc_ProductNote.DiscGroupId, recordNote.discGroupId, "Product V2 discGroupId: " + docArrayElementCount); //Verify discGroupDesc AssertIfNotNull(checkArgs, doc_ProductNote.DiscGroupDesc, recordNote.discGroupDesc, "Product V2 discGroupDesc: " + docArrayElementCount); //Verify linbuyId AssertIfNotNull(checkArgs, doc_ProductNote.LinebuyId, recordNote.linebuyId, "Product V2 linebuyId: " + docArrayElementCount); //Verify linebuyDesc AssertIfNotNull(checkArgs, doc_ProductNote.LinebuyDesc, recordNote.linebuyDesc, "Product V2 linebuyDesc: " + docArrayElementCount); //Verify altCode1 AssertIfNotNull(checkArgs, doc_ProductNote.Alt1Code, recordNote.alt1Code, "Product V2 altCode1: " + docArrayElementCount); //Verify altCodes AssertIfNotNull(checkArgs, sortString(doc_ProductNote.AltCodes.Trim()), sortString(recordNote.altCodes), "Product V2 altCodes: " + docArrayElementCount); //Verify altCodeType AssertIfNotNull(checkArgs, sortString(doc_ProductNote.AltCodeType.Trim()), sortString(recordNote.altCodeType), "Product V2 altCodeType: " + docArrayElementCount); break; } } docArrayElementCount++; } //closing the DB connection CloseDBConnection(); } }
//zet json om naar onze objecten en schrijft ze weg naar de databank. public void ConvertJsonPosts() { initNonExistingRepo(); using (StreamReader r = new StreamReader(@"C:\Users\Sander\Desktop\IntegratieProject-PoC-master\BL\TestData\textgaindump.json")) { var json = r.ReadToEnd(); //json omzetten in een data object RecordDTO recordDTO = JsonConvert.DeserializeObject <RecordDTO>(json); //een object aanmaken hoe dat wij het gaan gebruiken record record = new record(); record.records = new List <Post>(); //elk DTO object omzetten naar ons object foreach (var post in recordDTO.records) { Post postToAdd = new Post() { Date = post.Date, geo = post.geo, retweet = post.retweet, source = post.source, HashTags = new List <Hashtag>(), Words = new List <Word>(), Naam = new Naam(), sentiment = new sentiment(), urls = new List <url>(), mentions = new List <Mention>(), id = post.id }; postToAdd.Naam.Voornaam = post.Politician.First(); postToAdd.Naam.Achternaam = post.Politician.Last(); //zet voorlopig gewoon ruw de data om postToAdd.sentiment.polariteit = post.sentiment.First(); postToAdd.sentiment.objectiviteit = post.sentiment.Last(); //hash tags omzetten naar ons object foreach (var hashtag in post.HashTags) { Hashtag h = new Hashtag() { tag = hashtag }; postToAdd.HashTags.Add(h); } //words omzetten naar ons object foreach (var word in post.Words) { Word w = new Word() { word = word }; postToAdd.Words.Add(w); } foreach (var url in post.urls) { url u = new url() { URL = url }; postToAdd.urls.Add(u); } foreach (var mention in post.mentions) { Mention m = new Mention() { mention = mention }; postToAdd.mentions.Add(m); } record.records.Add(postToAdd); } //wegschrijven naar onze databank AddPosts(record.records); } }
/// <summary> /// 新建病历. /// </summary> /// <param name="recordDTO">传入数据.</param> /// <returns>Json.</returns> public ActionResult AddRecord(RecordDTO recordDTO) { Record record = new Record { Id = recordDTO.Id, Name = recordDTO.Name, Sex = recordDTO.Sex, Age = recordDTO.Age, Phone = recordDTO.Phone, DepartmentId = int.Parse(recordDTO.Department.Split(' ')[0]), BedId = int.Parse(recordDTO.Bed.Split(' ')[0]), MedicalCost = recordDTO.MedicalCost, Deposit = recordDTO.Deposit, Status = recordDTO.Status, InTime = DateTime.Now.ToString(), Account = GetRandomString.GenerateRandomNumber(), PassWord = "******", }; // 自增列用法 int recordId = Db.Insertable(record).ExecuteReturnIdentity(); // 生成日志 Log log = new Log { Id = 0, Time = DateTime.Now.ToString(), Content = "病历号:" + recordId + "-姓名:" + record.Name + "办理入院登记", }; // 自增列用法 Db.Insertable(log).ExecuteReturnIdentity(); // 生成账单 Bill bill = new Bill { Id = 0, RecordId = recordId, Time = DateTime.Now.ToString(), Status = "待支付", }; bill.Type = "押金"; bill.Cost = record.Deposit; Db.Insertable(bill).ExecuteReturnIdentity(); bill.Type = "医疗费"; bill.Cost = record.MedicalCost; Db.Insertable(bill).ExecuteReturnIdentity(); bill.Type = "床位费"; var department = Db.Queryable <Department>().Where(it => it.Id == record.DepartmentId).Single(); bill.Cost = department.Cost; Db.Insertable(bill).ExecuteReturnIdentity(); // 更新病床和科室 department.FreeBedNum--; var bed = Db.Queryable <Bed>().Where(it => it.Id == record.BedId).Single(); bed.IsFree = "已占用"; bed.RecordId = recordId; Db.Updateable(department).ExecuteCommand(); Db.Updateable(bed).ExecuteCommand(); // 新增家属 AddUser(record, recordId); return(Json(new { code = 200 }, JsonRequestBehavior.AllowGet)); }