public ActionResult Create(Sensor flower) { try { if (ModelState.IsValid) { db.AddToFlowers(flower); db.SaveChanges(); return RedirectToAction("Index"); } } catch (Exception ex) { ModelState.AddModelError(String.Empty, ex); } return View(flower); }
/// <summary> /// Deprecated Method for adding a new object to the Flowers EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToFlowers(Sensor sensor) { base.AddObject("Flowers", sensor); }
/// <summary> /// Create a new Sensor object. /// </summary> /// <param name="sensorId">Initial value of the SensorId property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="price">Initial value of the Price property.</param> /// <param name="article">Initial value of the Article property.</param> public static Sensor CreateSensor(global::System.Int32 sensorId, global::System.String name, global::System.Decimal price, global::System.String article) { Sensor sensor = new Sensor(); sensor.SensorId = sensorId; sensor.Name = name; sensor.Price = price; sensor.Article = article; return sensor; }
public ActionResult Create() { Sensor flower = new Sensor(); return View(flower); }