In the next code
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<ActionResult> Create([Bind(Include = "DispositivoID,Nombre,ClaveDispositivo,Activo,EmpresaID")] Modelo.Dispositivo dispositivo)
{
if (ModelState.IsValid)
{
//string deviceId = "minwinpc";
Device device;
try
{
device = await registryManager.AddDeviceAsync(new Device(dispositivo.Nombre)).Result;
}
catch (DeviceAlreadyExistsException)
{
device = await registryManager.GetDeviceAsync(dispositivo.Nombre).Result;
}
dispositivo.ClaveDispositivo = device.Authentication.SymmetricKey.PrimaryKey;
db.Dispositivos.Add(dispositivo);
db.SaveChanges();
return RedirectToAction("Index");
}
ViewBag.EmpresaID = new SelectList(db.Empresas, "EmpresaID", "Nombre", dispositivo.EmpresaID);
return View(dispositivo);
}
I have the next error:
Error CS1061 'Device' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'Device' could be found (are you missing a using directive or an assembly reference?)
In "Device" there are:
using System;
using Microsoft.Azure.Devices.Common;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace Microsoft.Azure.Devices
{
public class Device : IETagHolder
{
public Device();
public Device(string id);
[JsonProperty(PropertyName = "authentication")]
public AuthenticationMechanism Authentication { get; set; }
[JsonProperty(PropertyName = "cloudToDeviceMessageCount")]
public int CloudToDeviceMessageCount { get; }
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty(PropertyName = "connectionState")]
public DeviceConnectionState ConnectionState { get; }
[JsonProperty(PropertyName = "connectionStateUpdatedTime")]
public DateTime ConnectionStateUpdatedTime { get; }
[JsonProperty(PropertyName = "etag")]
public string ETag { get; set; }
[JsonProperty(PropertyName = "generationId")]
public string GenerationId { get; }
[JsonProperty(PropertyName = "deviceId")]
public string Id { get; }
[JsonProperty(PropertyName = "lastActivityTime")]
public DateTime LastActivityTime { get; }
[JsonConverter(typeof(StringEnumConverter))]
[JsonProperty(PropertyName = "status")]
public DeviceStatus Status { get; set; }
[JsonProperty(PropertyName = "statusReason")]
public string StatusReason { get; set; }
[JsonProperty(PropertyName = "statusUpdatedTime")]
public DateTime StatusUpdatedTime { get; }
}
}