public async Task <DeviceAddResultModel> AddAsync([NotNull] DeviceAddModel model, [NotNull] string appId, [NotNull] string appKey) { var appInfo = new ElectOneSignalAppOption(appId, appKey); return(await AddAsync(model, appInfo)); }
public async Task <DeviceAddResultModel> AddAsync([NotNull] DeviceAddModel model, [NotNull] ElectOneSignalAppOption appInfo) { model.AppId = appInfo.AppId; try { var result = await ElectOneSignalConstants.DefaultApiUrl .ConfigureRequest(config => { config.JsonSerializer = ElectOneSignalConstants.NewtonsoftJsonSerializer; }) .AppendPathSegment("players") .WithHeader("Authorization", $"Basic {appInfo.ApiKey}") .PostJsonAsync(model) .ReceiveJson <DeviceAddResultModel>() .ConfigureAwait(true); return(result); } catch (FlurlHttpException e) { var response = await e.GetResponseStringAsync().ConfigureAwait(true); throw new HttpRequestException(response); } }
public IActionResult Add() { var model = new DeviceAddModel() { }; return(View(model)); }
public static DeviceAddDomainModel RequestToDomain(this DeviceAddModel @this) { return(new DeviceAddDomainModel { name = @this.name, serial_number = @this.serial_number, type = @this.type }); }
public async Task <IActionResult> AddDevice(string user_id, [FromBody] DeviceAddModel model) { var response = await GetResultAsync <bool>( getItem : async() => await _deviceService.AddDeviceAsync(model.RequestToDomain()), modelState : ModelState ); return(Result(response)); }
public async Task <IActionResult> AddAsync([FromBody] DeviceAddModel mDevice) { if (!ModelState.IsValid) { return(HttpBadRequest(ModelStateError())); } var deviceId = await _deviceRepository.AddAsync(mDevice); return(CreatedAtRoute("GetByDeviceIdAsync", new { controller = "Devices", deviceId = deviceId }, mDevice)); }
// // GET: /Device/Add/<SiteId> public ActionResult Add(int SiteId) { try { var provider = new SiteProvider(DomainSession.GetDataContextForUserContext(this.HttpContext)); DeviceAddModel model = new DeviceAddModel(provider.GetById(SiteId)); return(View(model)); } catch (Exception e) { return(View()); } }
public async Task <ActionResult> Add(DeviceAddModel model) { try { var provider = new DeviceProvider(DomainSession.GetDataContextForUserContext(this.HttpContext)); model.Result = StatusResponseGenerator.GetStatusResponseResultForReturnParam(provider.Add(model.Device, model.LocationId, model.TypeId, model.DeviceSiteId)); return(View(model)); } catch (Exception e) { return(View()); } }
public int Add(DeviceAddModel mDevice) { var model = new Device { Voltage = mDevice.Voltage, Diameter = mDevice.Diameter, Torque = mDevice.Torque, }; _context.Devices.Add(model); _context.SaveChanges(); return(model.DeviceId); }
public async Task <int> AddAsync(DeviceAddModel mDevice) { var model = new Device { Voltage = mDevice.Voltage, Diameter = mDevice.Diameter, Torque = mDevice.Torque, }; _context.Devices.Add(model); await _context.SaveChangesAsync(); return(model.DeviceId); }
public IActionResult Add(DeviceAddModel model) { if (!ModelState.IsValid) { return(Json(new { state = "error", data = "提交信息验证失败" })); } try { var dal = new DeviceDal(); var p = mapper.Map <DeviceDefinition>(model); dal.Add(p); return(Json(new { state = "ok", data = 1 })); } catch (Exception ex) { return(Json(new { state = "error", data = ex.Message })); } }
public async Task <DeviceAddResultModel> AddAsync([NotNull] DeviceAddModel model, [NotNull] string appId) { var appInfo = Options.Apps.Single(x => x.AppId == appId); return(await AddAsync(model, appInfo)); }