public void UpdateDeviceById(int id, Device device) { DatabaseMapping databaseMapping = _deviceContext.DatabaseMappings.Find(id); if (databaseMapping == null) { return; } switch (databaseMapping.DeviceTypeId) { case 1: if (device is Clock) { _deviceContext.Entry((Clock)device).State = EntityState.Modified; _deviceContext.SaveChanges(); } break; case 2: if (device is Microwave) { _deviceContext.Entry((Microwave)device).State = EntityState.Modified; _deviceContext.SaveChanges(); } break; case 3: if (device is Oven) { _deviceContext.Entry((Oven)device).State = EntityState.Modified; _deviceContext.SaveChanges(); } break; case 4: if (device is Fridge) { _deviceContext.Entry((Fridge)device).State = EntityState.Modified; _deviceContext.SaveChanges(); } break; } }
private void AddDevice(Device device) { myDevices.Add(newDeviceID, device); newDeviceID++; context.Session["devices"] = GetDevices(); context.Session["newDeviceID"] = newDeviceID; // Обновление страницы браузера должно работать корректно... HttpContext.Current.Response.Redirect(HttpContext.Current.Request.RawUrl); //Repeater1.DataSource = deviceManager.GetDevices(); //Repeater1.DataBind(); }