public ActionResult Create(DotViewModels dotView) { DotType dotType = new DotType(); dotType = db.DotTypes.Find(dotView.SelectedValuesT.FirstOrDefault()); Dot dot = new Dot(); dot = dotView.Dot; dot.Type = dotType.Id; db.Dots.Add(dot); db.SaveChanges(); IPCamDot iPCamDot = new IPCamDot(); iPCamDot.DotId = dot.Id; iPCamDot.IP = dotView.IP; iPCamDot.Port = dotView.Port; iPCamDot.Login = dotView.Login; iPCamDot.Password = dotView.Password; db.IPCamDots.Add(iPCamDot); db.Dots.Add(dot); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: Dots/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } DotViewModels dotViewModels = new DotViewModels(); Dot dot = await db.Dots.FindAsync(id); if (dot == null) { return(HttpNotFound()); } var dotType = await db.DotTypes.FindAsync(dot.Type); var iPCamDot = await db.IPCamDots.Where(x => x.DotId == dot.Id).FirstOrDefaultAsync(); dotViewModels.Dot = dot; dotViewModels.IP = iPCamDot.IP; dotViewModels.Login = iPCamDot.Login; dotViewModels.Password = iPCamDot.Password; dotViewModels.Port = iPCamDot.Port; if (dotType.Type == "IP Cam") { return(View("IPCamDotDetails", dotViewModels)); } return(View(dot)); }
// GET: Dots/Create public ActionResult Create(int nodeId) { Node node = db.Nodes.Find(nodeId); DotViewModels dotView = new DotViewModels(); dotView.Dot.NodeId = node.Id; dotView.DotTypes = db.DotTypes.ToList(); List <SelectListItem> itemsT = new List <SelectListItem>(); foreach (var item in dotView.DotTypes) { itemsT.Add(new SelectListItem { Value = item.Id.ToString(), Text = item.Type }); } dotView.ValuesT = itemsT; return(View(dotView)); }