コード例 #1
0
ファイル: DeviceDomain.cs プロジェクト: asc793/teknolojiKovan
 public bool DeleteDevice(Guid Id)
 {
     try
     {
         tKovanContext ctx = new tKovanContext();
         TeknolojiKovaniWebApi.Models.EntityClass.Device eDevice = ctx.Device.Where(x => x.Id == Id).FirstOrDefault();
         ctx.Device.Remove(eDevice);
         ctx.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: DeviceDomain.cs プロジェクト: asc793/teknolojiKovan
        public bool UpdateDevice(DTOs.DeviceRead device)
        {
            try
            {
                tKovanContext ctx = new tKovanContext();
                TeknolojiKovaniWebApi.Models.EntityClass.Device eDevice = ctx.Device.Single(x => x.Id == device.Id);

                eDevice.DataSendInterval = device.DataSendInterval;
                eDevice.EnvironmentId    = device.EnvironmentId;
                eDevice.MacNo            = device.MacNo;
                eDevice.Name             = device.Name;
                eDevice.ProfileId        = device.ProfileId;
                //eDevice.UserId = device.UserId;
                //eDevice.UserId = device.UserId;
                //ctx.Device.Add(eDevice);
                ctx.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #3
0
        public static DeviceRead GetCurrentDevice()
        {
            string token = HttpContext.Current.Request.Headers["token"];

            if (string.IsNullOrEmpty(token))
            {
                return(null);
            }
            else
            {
                tKovanContext             ctx = new tKovanContext();
                Models.EntityClass.Device dev = ctx.Device.FirstOrDefault(i => i.CurrentToken == token.ToString());

                DeviceRead res = null;

                if (dev != null)
                {
                    res = Utilities.Map <Models.EntityClass.Device, DeviceRead>(dev, res);
                }

                return(res);
            }
        }