Пример #1
0
        //
        // GET: /Meter/Create

        public ActionResult CreateElec(int propertyId)
        {
            try
            {
                ElectricityMeterViewModel model = new ElectricityMeterViewModel();
                model.StartDate         = DateTime.Now;
                model.BelongsToProperty = propertyId;
                return(View(model));
            }
            catch
            {
                return(View("Error"));
            }
        }
Пример #2
0
        public ActionResult CreateElec(ElectricityMeterViewModel model)
        {
            try
            {
                int propertyId = model.BelongsToProperty;

                ///submit creation and check for success
                EMResponse response = JsonConvert.DeserializeObject <EMResponse>(emAPI.createElectricityMeter(model.Meter.SerialNo, model.Meter.ScalingFactor,
                                                                                                              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());
            }
        }