public void createPrinterModel(MetroLabel printerModelIDLab, MetroTextBox room, MetroComboBox titul) { LocationID = Convert.ToInt32(printerModelIDLab.Text); using (ContextModel db = new ContextModel()) { if (LocationID == 0) { LocationRoom location = new LocationRoom { Room = room.Text.Trim(), TitulID = Convert.ToInt32(titul.SelectedValue) }; db.LocationRoom.Add(location); } else { var mpToUpdate = db.LocationRoom.SingleOrDefault(pm => pm.LocationID == LocationID); if (mpToUpdate != null) { mpToUpdate.Room = room.Text; mpToUpdate.TitulID = Convert.ToInt32(titul.SelectedValue); } } db.SaveChanges(); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,RoomName,RoomShortCode")] LocationRoom locationRoom) { if (id != locationRoom.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(locationRoom); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationRoomExists(locationRoom.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(locationRoom)); }
public void CreateUpdate() { int LocationID = Convert.ToInt32(ID); using (ContextModel db = new ContextModel()) { if (LocationID == 0) { LocationRoom location = new LocationRoom { Room = RoomNumber, TitulID = Convert.ToInt32(TitulCB.SelectedValue) }; db.LocationRoom.Add(location); } else { var mpToUpdate = db.LocationRoom.SingleOrDefault(pm => pm.LocationID == LocationID); if (mpToUpdate != null) { mpToUpdate.Room = RoomNumber; mpToUpdate.TitulID = Convert.ToInt32(TitulCB.SelectedValue); } } db.SaveChanges(); } }
public async Task <IActionResult> Create([Bind("Id,RoomName,RoomShortCode")] LocationRoom locationRoom) { if (ModelState.IsValid) { _context.Add(locationRoom); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(locationRoom)); }
public void Delete() { int LocationID = Convert.ToInt32(ID); using (ContextModel db = new ContextModel()) { LocationRoom location = db.LocationRoom .Where(p => p.LocationID == LocationID) .FirstOrDefault(); db.LocationRoom.Remove(location); db.SaveChanges(); } }
public void deleteLocation(string metroLabel) { LocationID = Convert.ToInt32(metroLabel); using (ContextModel db = new ContextModel()) { LocationRoom location = db.LocationRoom .Where(p => p.LocationID == LocationID) .FirstOrDefault(); db.LocationRoom.Remove(location); db.SaveChanges(); } }
public ActionResult getr(String namestring, String logstring) { LocationRoom LocRoom = new LocationRoom(); LocRoom.Name = namestring; var ListLog = new List <Log>(); String[] rawlog = logstring.Split("|"); foreach (string str in rawlog) { if (str != "") { String[] infomass = str.Split(" "); Log log = new Log(); log.SSID = infomass[0]; log.BSSID = infomass[1]; log.AvgLevel = Convert.ToDouble(infomass[2]); log.LocationId = LocRoom.Id; log.LocRomm = LocRoom; ListLog.Add(log); } } if (List.ContainsKey(LocRoom.Name)) { foreach (Log lg in ListLog) { if (List[LocRoom.Name].Find(x => x.BSSID.Contains(lg.BSSID)) != null) { List[LocRoom.Name].Find(x => x.BSSID.Contains(lg.BSSID)).AvgLevel += lg.AvgLevel; List[LocRoom.Name].Find(x => x.BSSID.Contains(lg.BSSID)).number_of_Mentions++; //xd[LocRoom].Find(x => x.BSSID.Contains(LogList.BSSID)).AvgLevel += Convert.ToDouble(wifiInfo.level.Split("dBm")[0]); // xd[LocRoom].Find(x => x.BSSID.Contains(LogList.BSSID)).NumBerOfMentions++; } else { List[LocRoom.Name].Add(lg); } } } else { List.Add(LocRoom.Name, ListLog); } return(Ok()); }
public void Summ() { foreach (var keyvalue in List) { LocationRoom LocRoom = new LocationRoom(); LocRoom.Name = keyvalue.Key; _ctx.LocationRooms.Add(LocRoom); _ctx.SaveChanges(); foreach (var value in keyvalue.Value) { Log log = new Log(); log.SSID = value.SSID; log.BSSID = value.BSSID; log.AvgLevel = value.AvgLevel / (value.number_of_Mentions + 1); log.number_of_Mentions = value.number_of_Mentions; log.LocationId = LocRoom.Id; log.LocRomm = LocRoom; _ctx.Logs.Add(log); } _ctx.SaveChanges(); } }
public string SummID(string Room) { bool flag = false; foreach (var keyvalue in List) { LocationRoom LocRoom = new LocationRoom(); if (keyvalue.Key == Room) { LocRoom.Name = keyvalue.Key; _ctx.LocationRooms.Add(LocRoom); _ctx.SaveChanges(); flag = true; foreach (var value in keyvalue.Value) { Log log = new Log(); log.SSID = value.SSID; log.BSSID = value.BSSID; log.AvgLevel = value.AvgLevel / (value.number_of_Mentions + 1); log.number_of_Mentions = value.number_of_Mentions; log.LocationId = LocRoom.Id; log.LocRomm = LocRoom; _ctx.Logs.Add(log); } _ctx.SaveChanges(); } } if (flag == true) { return("Add ID"); } else { return("No ID"); } }