Ejemplo n.º 1
0
        public void DeleteDevice(DDevaceModel Device)
        {
            d_tariff dtd = GetTariffById(Device.Id);

            beEbergyContext.d_tariffs.DeleteOnSubmit(dtd);

            Commit();
        }
Ejemplo n.º 2
0
        public JsonResult DeviceAjaxHandler(DDevaceModel data)
        {
            DDevaceModel result = null;

            if(Request.Params.Get("action") == "create")
            {
                result = da.InsertDevice(data);
            }
            else if(Request.Params.Get("action") == "edit")
            {
                result = da.UpdateDevice(data);
            }
            else if(Request.Params.Get("action") == "remove")
            {
                da.DeleteDevice(data);
                result = data;
            }

            return Json(new
            {
                data = result
            }, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 3
0
        public DDevaceModel UpdateDevice(DDevaceModel Device)
        {
            d_device dd = GetDeviceById(Device.Id);

            dd.code = Device.code;
            dd.name = Device.name;
            dd.coefficient = Device.coefficient;
            dd.device_id = Device.TypeDevice.Id;
            dd.tariff_Id = Device.Tariff.Id;

            Commit();

            Device.TypeDevice.name = dd.d_type_device.name;

            return Device;
        }
Ejemplo n.º 4
0
        public DDevaceModel InsertDevice(DDevaceModel Device)
        {
            d_device dv = new d_device();

            dv.code = Device.code;
            dv.name = Device.name;
            dv.coefficient = Device.coefficient;
            dv.device_id = Device.TypeDevice.Id;
            dv.tariff_Id = Device.Tariff.Id;

            beEbergyContext.d_devices.InsertOnSubmit(dv);
            Commit();

            Device.Id = dv.Id;

            return Device;
        }