// // GET: /Meter/Create public ActionResult CreateGas(int propertyId) { try { GasMeterViewModel model = new GasMeterViewModel(); model.BelongsToProperty = propertyId; model.StartDate = DateTime.Now; return View(model); } catch { return View("Error"); } }
public ActionResult CreateGas(GasMeterViewModel model) { try { ///submit create and check for success int propertyId = model.BelongsToProperty; EMResponse response = JsonConvert.DeserializeObject<EMResponse>(emAPI.createGasMeter(model.Meter.SerialNo, model.Meter.MeterCoefficient, model.Meter.NumbDigits, model.StartDate.ToString(), propertyId)); if (response.status == EMResponse.OK) { return RedirectToAction("Home", "Property", new { id = propertyId }); } else { return View("Error"); } } catch { return View(); } }