public async Task <IActionResult> Put(int id, [FromBody] Accident inputAccident) { var accident = await db.Accidents.FindAsync(id); if (accident == null) { return(NotFound()); } try { accident.Name = inputAccident.Name; accident.Description = inputAccident.Description; db.Accidents.Update(accident); } catch (Exception e) { return(BadRequest(e)); } await db.SaveChangesAsync(); return(NoContent()); }
public async Task Post([FromBody] Accident accdnt) { if (ModelState.IsValid) { await _accidentRepository.Add(accdnt); } }
public void DisplayMessage(BaseAccident data) { if (data.GetType() == typeof(Accident)) { Lucky.LuckyUtils.Log("destroy"); Accident accident = data as Accident; Lucky.LuckyUtils.Log(accident.type + "delete acciednt " + accident.location); if (accident.type == AccidentType.airport) { if (AirPlanewarndic.ContainsKey(accident.location)) { Destroy(AirPlanewarndic[accident.location].gameObject); AirPlanewarndic.Remove(accident.location); } } else { if (Trainwarndic.ContainsKey(accident.location)) { Destroy(Trainwarndic[accident.location].gameObject); Trainwarndic.Remove(accident.location); } } } }
public void Put(int id, [FromBody] Accident accdnt) { accdnt.Id = id; if (ModelState.IsValid) { _accidentRepository.Update(accdnt); } }
public AccidentModel() { using (var webClient = new WebClient()) { String AccidentJson_Data = webClient.DownloadString("https://cincinnatiaccidents.azurewebsites.net/api/accidents/downtown"); AccidentData = Accident.FromJson(AccidentJson_Data); } }
public async Task <IActionResult> GetAccidentAsync([FromRoute] string accidentId) { Accident accident = await this.accidentService.GetAccidentAsync(accidentId) .ConfigureAwait(false); return(Ok(AccidentDto.From(accident))); }
private void btnStart_Click(object sender, RoutedEventArgs e) { string path = @"C:\Users\ГерценЕ\Documents\visual studio 2015\Projects\StatisticsAccedent\StatisticsAccedent\2010 Fatalities by Type.xlsx"; FileInfo template = new FileInfo(path); // ExcelPackage package = new ExcelPackage(); using (ExcelPackage package = new ExcelPackage(template, true)) { ExcelWorksheet workshet = package.Workbook.Worksheets["Motorcyles"]; for (int i = 2; i < workshet.Dimension.End.Row; i++) { //var test = workshet.Cells[i, 1].Value; Accident accident = new Accident(); accident.AccidentDate = DateTime.Parse(workshet.Cells[i, 1].Value.ToString()); accident.DayOfWeek = workshet.Cells[i, 2].Value.ToString(); accident.Country = workshet.Cells[i, 4].Value.ToString(); accident.Age = Int32.Parse(workshet.Cells[i, 12].Value.ToString()); accident.Gender = workshet.Cells[i, 13].Value.ToString(); accidents.Add(accident); } } // Two step SqlConnection con = new SqlConnection(); con.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; SqlCommand sc = new SqlCommand(); sc.Connection = con; try { con.Open(); tbStatus.Text += con.State; foreach (Accident item in accidents) { string sf = string.Format("INSERT INTO Accidents (AccidentDate, County, Age, Gender, DayOfWeek)" + "VALUES ('{0}','{1}','{2}','{3}','{4}')", string.Format("{0:yyyy-MM-dd}", item.AccidentDate.Date), item.Country, item.Age, item.Gender, item.DayOfWeek ); sc.CommandText = sf; sc.ExecuteNonQuery(); } }catch (Exception ex) { tbStatus.Text += ex.Message; } finally { con.Close(); } }
internal static AccidentDto From(Accident accident) => new AccidentDto { Id = accident.Id, ExternalId = accident.ExternalId, Date = accident.Date, Location = accident.Location != null?LocationDto.From(accident.Location) : null, Tags = accident.Tags };
internal static AccidentEntity From(Accident model) => new AccidentEntity { Id = model.Id, ExternalId = model.ExternalId, Date = model.Date, Location = LocationEntity.From(model.Location), Tags = model.Tags?.ToArray() ?? new string[0] };
public ActionResult Edit(Accident accident) { using (DatabaseContext db = new DatabaseContext()) { db.Entry(accident).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction("Index", "AdminPanelAccidents")); }
public void Update(Accident item1) { using (System.Data.IDbConnection dbConnection = GetConnection()) { string sQuery = @"UPDATE AccidentTable SET Verified = @Verified WHERE Id = @Id"; dbConnection.Open(); dbConnection.Query(sQuery, item1); } }
public List <TrafficMessage> HandlingAccident(System.Object taccident) { //handle ticket delay Accident accident = taccident as Accident; TicketsOperaton tickets = new TicketsOperaton(); List <int> routine_id = tickets.DelayTickets(accident.starttime, accident.location, accident.duration, accident.type); TimeManager.instance.Delay(routine_id); return(new List <TrafficMessage>()); }
public FAccident() { InitializeComponent(); contractModel = new ContractModel(); listContract = new DataTable(); listAccident = new DataTable(); accidentModel = new AccidentModel(); selectedFunction = rowIndex = 0; accident = new Accident(); }
public async Task <IActionResult> CarOperational(ApiRequest vehicle) { try { Vehicle fmsVehicle = (from v in dbContext.Vehicles where v.VehicleNumber == vehicle.VehicleNumber select v).SingleOrDefault(); fmsVehicle.Status = "maintained"; fmsVehicle.AccidentalStatus = AccidentalMaintenanceStatus.Done; dbContext.SaveChanges(); Accident accident = (from a in dbContext.Accidents where a.FMSVehicleId == fmsVehicle.Id && a.MaintenanceStatus == MaintenanceStatus.NotInitiated select a).SingleOrDefault(); accident.MaintenanceStatus = MaintenanceStatus.Operational; accident.CarOperationalTime = PakistanDateTime.Now; accident.LastUpdated = PakistanDateTime.Now; if (fmsVehicle.EmergencyStatus == EmergencyMaintenanceStatus.Pending) { fmsVehicle.Status = "emergency"; } else if (fmsVehicle.PeriodicStatus == PeriodicMaintenanceStatus.Pending) { fmsVehicle.Status = "periodic"; } else { fmsVehicle.Status = "maintained"; } dbContext.SaveChanges(); string title = $"Accidental Job Vehicle Number {vehicle.VehicleNumber}"; string notification = $"Vehicle Number {vehicle.VehicleNumber} marked as operational"; await hubContext.Clients.All.SendAsync("ReceiveMessageAllUsers", User.Identity.Name, title, notification); await SMSService.SendSMS(title + ": " + notification, "03035650720"); SMSService.SendMail(title, notification, "*****@*****.**"); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }
public async Task <Accident> CreateAccidentAsync(Accident accident) { accident.Id = Guid.NewGuid().ToString(); AccidentEntity accidentEntity = AccidentEntity.From(accident); await this.accidentRepository .InsertOneAsync(accidentEntity) .ConfigureAwait(false); return(accident); }
public IHttpActionResult PostAccident(Accident accident) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.Accidens.Add(accident); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = accident.ID }, accident)); }
public async Task <IActionResult> PostAccident([FromBody] Accident accident) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Accident.Add(accident); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAccident", new { id = accident.Id }, accident)); }
public void Write(TProtocol oprot) { oprot.IncrementRecursionDepth(); try { TStruct struc = new TStruct("TDDIRiskParameterUnion"); oprot.WriteStructBegin(struc); TField field = new TField(); if (RiskParameter != null && __isset.RiskParameter) { field.Name = "RiskParameter"; field.Type = TType.Struct; field.ID = 1; oprot.WriteFieldBegin(field); RiskParameter.Write(oprot); oprot.WriteFieldEnd(); } if (Situation != null && __isset.Situation) { field.Name = "Situation"; field.Type = TType.Struct; field.ID = 2; oprot.WriteFieldBegin(field); Situation.Write(oprot); oprot.WriteFieldEnd(); } if (Accident != null && __isset.Accident) { field.Name = "Accident"; field.Type = TType.Struct; field.ID = 3; oprot.WriteFieldBegin(field); Accident.Write(oprot); oprot.WriteFieldEnd(); } if (OperationMeasure != null && __isset.OperationMeasure) { field.Name = "OperationMeasure"; field.Type = TType.Struct; field.ID = 4; oprot.WriteFieldBegin(field); OperationMeasure.Write(oprot); oprot.WriteFieldEnd(); } oprot.WriteFieldStop(); oprot.WriteStructEnd(); } finally { oprot.DecrementRecursionDepth(); } }
public async Task <IActionResult> Create([Bind("ID,Date,Time,Type,Damages,Notes,UserId,LabDayId")] Accident accident) { if (ModelState.IsValid) { _context.Add(accident); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["LabDayId"] = new SelectList(_context.LabDay, "ID", "ID", accident.LabDayId); ViewData["UserId"] = new SelectList(_context.Users, "Id", "Id", accident.UserId); return(View(accident)); }
private void buttonEdytuj_Click(object sender, EventArgs e) { foreach (DataGridViewRow row in this.dataGridView1.SelectedRows) { Accident accident = row.DataBoundItem as Accident; if (accident != null) { AccidentForm accidentForm = new AccidentForm(accident); accidentForm.MdiParent = this.ParentForm; accidentForm.Show(); } } }
public async Task <int> UpdateAccident(Guid accidentId, Accident updatedAccidentInfo) { var accident = await GetAccidentById(accidentId); accident.Fine = updatedAccidentInfo.Fine; accident.CoveredByInsurance = updatedAccidentInfo.CoveredByInsurance; accident.AccidentTime = updatedAccidentInfo.AccidentTime; accident.IsOwnFault = updatedAccidentInfo.IsOwnFault; accident.TripId = updatedAccidentInfo.TripId; _dbContext.Entry(accident).State = EntityState.Modified; return(await SaveChanges()); }
public async Task Add(Accident item) { item.Location = await _accidentRepository.GetPlaceName(11.25, 75.78); using (IDbConnection dbConnection = GetConnection()) { string sQuery = @"INSERT INTO AccidentTable (Lplate,Longitude, Latitude ,Name ,Age ,Location ,Description) VALUES(@Lplate, @Longitude, @Latitude, @Name ,@Age ,@Location, @Description)"; dbConnection.Open(); dbConnection.Execute(sQuery, item); } }
void PushAccident(Accident item) { TimeManager.instance.AddAccidentExecute(item, HandleAccident, false); Accident eitem = new Accident { duration = item.duration, location = item.location, starttime = item.starttime.AddMinutes(item.duration), type = item.type, text = item.text }; TimeManager.instance.AddAccidentExecute(eitem, null, true); }
public Accident AccidentStringProcess(Accident accident) { string title = accident.text.title; string description = accident.text.description; string[] dictIn, dictOut; int duration = accident.duration; string sDate = accident.starttime.Month.ToString() + "月" + accident.starttime.Day.ToString() + "日"; string sTime = accident.starttime.TimeOfDay.ToString().Remove(5, 3); string eDate = accident.starttime.AddMinutes(duration).Month.ToString() + "月" + accident.starttime.AddMinutes(duration).Day.ToString() + "日"; string eTime = accident.starttime.AddMinutes(duration).TimeOfDay.ToString().Remove(5, 3); duration = duration / 60; dictIn = new string[7] { "<Spos>", "<Epos>", "<Sdate>", "<Edate>", "<Stime>", "<Etime>", "<Duration>" }; dictOut = new string[7] { "Spos", "Epos", sDate, eDate, sTime, eTime, duration.ToString() }; //Debug.Log(accident.type); switch (accident.type) { case AccidentType.rail: { Debug.Log(accident.location); dictOut[0] = CityUtil.Instance.GetEdgeCity(accident.location).start_node; dictOut[1] = CityUtil.Instance.GetEdgeCity(accident.location).end_node; break; } case AccidentType.airport: { dictOut[0] = CityUtil.Instance.GetCityName(accident.location); break; } } if (duration == 0) { dictOut[6] = "不足一"; } for (int i = 0; i < dictIn.Length; i++) { accident.text.title = accident.text.title.Replace(dictIn[i], dictOut[i]); accident.text.description = accident.text.description.Replace(dictIn[i], dictOut[i]); } //Debug.Log(accident.text.description); return(accident); }
public IHttpActionResult DeleteAccident(int id) { Accident accident = db.Accidens.Find(id); if (accident == null) { return(NotFound()); } db.Accidens.Remove(accident); db.SaveChanges(); return(Ok(accident)); }
public async Task <int> AddAccident(Accident newAccident) { var tripOfAccident = newAccident.Trip; newAccident.Id = Guid.NewGuid().ToString(); if (newAccident.AccidentTime > tripOfAccident.TripDate) { await _dbContext.Accidents.AddAsync(newAccident); return(await SaveChanges()); } throw new Exception("The associated trip is not valid"); }
public cAccident(Accident model) { this.ID = model.ID; this.UserID = model.UserID; this.Username = model.User.Username; this.District = model.District.SchoolDistrictName; this.Building = model.Building.BuildName; this.Floor = model.Floor; this.Room = model.Room; this.AccidentType = model.AccidentType; this.Description = model.Description; this.Time = model.Time.ToString(); this.Statu = model.StatuAsInt; this.ImagePath = model.PicturePath; }
public override string ToString() { StringBuilder __sb = new StringBuilder("TDDIRiskParameterUnion("); bool __first = true; if (RiskParameter != null && __isset.RiskParameter) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("RiskParameter: "); __sb.Append(RiskParameter == null ? "<null>" : RiskParameter.ToString()); } if (Situation != null && __isset.Situation) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Situation: "); __sb.Append(Situation == null ? "<null>" : Situation.ToString()); } if (Accident != null && __isset.Accident) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("Accident: "); __sb.Append(Accident == null ? "<null>" : Accident.ToString()); } if (OperationMeasure != null && __isset.OperationMeasure) { if (!__first) { __sb.Append(", "); } __first = false; __sb.Append("OperationMeasure: "); __sb.Append(OperationMeasure == null ? "<null>" : OperationMeasure.ToString()); } __sb.Append(")"); return(__sb.ToString()); }
public void CreateAccident(AccidentType type, int location, int duration, DateTime starttime, int text) { Accident accident = new Accident { duration = duration, location = location, starttime = starttime, type = type, text = accidentTexts[text] }; Debug.Log(accident.starttime); accident = stringProcess.AccidentStringProcess(accident); PushAccident(accident); CreateAccidentWarning(accident); }
public bool AddAccident(long tripID, string accidentDesc, string caseNumber, string comments, DateTime accidentDate, string pointOfAcident) { Accident NewAccident = new Accident() { TripId = tripID, AccidentDescription = accidentDesc, CaseNumber = caseNumber, Comment = comments, AccidentDate = accidentDate, AccidentLocation = pointOfAcident }; this.m_Context.Accidents.Add(NewAccident); return(this.m_Context.SaveChanges() > 0); }
public async Task <IActionResult> PostBill(AccidentBill bill) { try { var currentUser = (from u in dbContext.Users where u.Email == User.Identity.Name select u).FirstOrDefault(); FMSAccidentalCheck check = (from c in dbContext.FMSAccidentalCheckList where c.Id == bill.CheckPointId select c).SingleOrDefault(); check.MaintenanceStatus = CheckMaintenanceStatus.InProgress; check.Remarks = bill.Remarks; FMSAccidentalCheckComment newComment = new FMSAccidentalCheckComment() { Id = Guid.NewGuid(), FMSAccidentalCheckId = check.Id, FMSAccidentId = check.FMSAccidentId, Comment = bill.BillAmount.ToString(), FMSUserId = new Guid((from u in dbContext.Users where u.Email == User.Identity.Name select u.Id).SingleOrDefault()), FMSVehicleId = check.FMSVehicleId, VehicleNumber = check.VehicleNumber, LastUpdated = DateTime.Now, Mentions = "" }; await dbContext.FMSAccidentalCheckComments.AddAsync(newComment); bill.Id = new Guid(); await dbContext.AccidentBills.AddAsync(bill); check.CommentCount = await(from c in dbContext.FMSAccidentalCheckComments where c.FMSAccidentalCheckId == bill.CheckPointId select c).CountAsync(); Accident accident = await dbContext.Accidents.Where(x => x.Id == check.FMSAccidentId).Select(x => x).SingleOrDefaultAsync(); accident.LastUpdated = PakistanDateTime.Now; check.LastUpdated = PakistanDateTime.Now; await dbContext.SaveChangesAsync(); return(Ok()); } catch (Exception ex) { return(BadRequest(ex.ToString())); } }