// To protect from overposting attacks, enable the specific properties you want to bind to. // For more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } _context.Attach(Controller).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ControllerExists(Controller.Id)) { return(NotFound()); } else { throw; } } return(RedirectToPage("./AddController")); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { return(Page()); } Controller.User = username; type = Controller.Type; Controller.Values = new string[0]; if (Controller.Type == "Датчик Температуры") { Controller.Type = "temperature"; Controller.Settings = start_temp + '|' + start_cool + '|' + end_cool + '|' + start_heat + '|' + end_heat + '|' + max_temp + '|' + min_temp + '|' + interval_temp; } else if (Controller.Type == "Датчик Давления") { Controller.Type = "pressure"; Controller.Settings = interval_press; } else if (Controller.Type == "Датчик Движения") { Controller.Type = "movement"; Controller.Settings = sensetivity; } else if (Controller.Type == "Датчик Освещения") { Controller.Type = "lightning"; Controller.Settings = interval_light + '|' + start_light_day + '|' + end_light_day; } else if (Controller.Type == "Датчик Влажности") { Controller.Type = "humidity"; Controller.Settings = start_humi + '|' + start_pouring + '|' + end_pouring + '|' + interval_humi; } else { return(RedirectToPage("./AddController")); } if (_context.Controllers.Find(Controller.Id) == null) { _context.Controllers.Add(Controller); } await _context.SaveChangesAsync(); return(RedirectToPage("./AddController")); }
public async Task <IActionResult> OnPostAsync(string id) { if (id == null) { return(NotFound()); } Controller = await _context.Controllers.FindAsync(id); if (Controller != null) { _context.Controllers.Remove(Controller); await _context.SaveChangesAsync(); } return(RedirectToPage("./AddController")); }