Exemplo n.º 1
0
        public async Task <IActionResult> GetSettings(string id)
        {
            var setting = await _repo.Filter <DeviceSettings>(x => x.DeviceId == id).FirstOrDefaultAsync();

            if (setting == default)
            {
                return(NotFound());
            }
            var result = new DeviceSettingsViewModel
            {
                _id           = setting.Id,
                Id            = setting.DeviceId,
                Date          = setting.UpdatedDt,
                Flowhanac     = setting.Flowhanac,
                Flowmax       = setting.Flowmax,
                Flowproc      = setting.Flowproc,
                Dpgorcakic    = setting.Dpgorcakic,
                Kgorcakic     = setting.Kgorcakic,
                FlowAutoOnoff = await _repo.FilterAsNoTracking <FlowSettings>(x => true).Select(x => x.On).FirstOrDefaultAsync(),
                Onoff         = setting.Onoff,
                Pressgorcakic = setting.Pressgorcakic
            };

            return(Ok(result));
        }
Exemplo n.º 2
0
 public static DeviceSettingsViewModel ResolveDeviceSettingsViewModel(IMainController controller)
 {
     if (deviceSettingsViewModel == null)
     {
         deviceSettingsViewModel = new DeviceSettingsViewModel(controller);
     }
     return(deviceSettingsViewModel);
 }
Exemplo n.º 3
0
        public ActionResult DeviceSettings(string DeviceId)
        {
            DeviceSettingsViewModel model = new DeviceSettingsViewModel();

            model.DeviceList = new List <SelectListItem>();

            // Get list of devices
            DataTable dt = Data.GetData(DataBase.Api, CommandType.StoredProcedure, "Api_GetDeviceList");

            if (dt != null || dt.Rows.Count > 0)
            {
                model.DeviceList = dt.AsEnumerable().Select(m => new SelectListItem()
                {
                    Value = Convert.ToString(m["DeviceId"]),
                    Text  = Convert.ToString(m["DeviceId"])
                }).ToList();
            }

            //ViewData["DeviceId"] = model.DeviceList;

            if (string.IsNullOrWhiteSpace(DeviceId) && model.DeviceList.Count > 0)
            {
                DeviceId = model.DeviceList.First().Value;
            }

            // Get device configuration
            dt = null;
            dt = new DataTable();

            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("DeviceId", DeviceId));

            dt = Data.GetData(DataBase.Api, CommandType.StoredProcedure, "Master_GetDeviceSettings", parameters.ToArray());

            if (dt != null || dt.Rows.Count > 0)
            {
                var tModel = dt.AsEnumerable().Select(m => new DeviceSettingsViewModel()
                {
                    DeviceId = Convert.ToString(m["IMEINo"]),
                    Odometer = Convert.ToInt32(m["Odometer"]),
                }).FirstOrDefault();
                if (tModel != null)
                {
                    model.DeviceId = tModel.DeviceId;
                    model.Odometer = tModel.Odometer;
                }
            }

            model = model ?? new DeviceSettingsViewModel();
            return(View(model));
        }
Exemplo n.º 4
0
        public DeviceSettingsPage()
        {
            InitializeComponent();

            BindingContext = viewModel = new DeviceSettingsViewModel();

            MessagingCenter.Subscribe <DeviceSettingsViewModel>(this, "DeviceConnectedFailed", async(sender) =>
            {
                await OnDeviceConnectionFailed();
            });

            MessagingCenter.Subscribe <DeviceSettingsViewModel, string>(this, "DeviceConnectedError", async(sender, message) =>
            {
                await OnDeviceConnectionError(message);
            });
        }
Exemplo n.º 5
0
        public ActionResult DeviceSettings(DeviceSettingsViewModel model)
        {
            List <SqlParameter> parameters = new List <SqlParameter>();

            parameters.Add(new SqlParameter("DeviceId", model.DeviceId));
            parameters.Add(new SqlParameter("Odometer", model.Odometer));

            try
            {
                Data.StoreData_ExecuteNonQuery(DataBase.Api, CommandType.StoredProcedure, "Master_SaveDeviceSettings", parameters.ToArray());
                TempData["Result"] = true;
            }
            catch (Exception ex)
            {
                TempData["Result"] = false;
            }
            //return DeviceSettings(model.DeviceId);
            return(RedirectToAction("DeviceSettings", new { DeviceId = model.DeviceId }));
        }
        public DeviceSettingsTrigger()
        {
            InitializeComponent();

            DataContext = new DeviceSettingsViewModel();
        }