Exemplo n.º 1
0
        public Guid CreateSensor(string owner, IRegisterableModel model)
        {
            RegisteredUser user       = this.context.Users.First(x => x.UserName == owner);
            DateTime       createDate = DateTime.Now;
            List <History> history    = new List <History> {
                new History()
                {
                    Id = Guid.NewGuid(), UpdateDate = createDate
                }
            };
            Sensor sensor = new Sensor
            {
                Id           = Guid.NewGuid(),
                Url          = model.Url,
                Name         = model.Name,
                RefreshRate  = model.RefreshRate,
                MinValue     = model.MinValue,
                MaxValue     = model.MaxValue,
                IsPublic     = model.IsPublic,
                CurrentValue = null,
                LastUpdated  = createDate
            };

            user.OwnSensors.Add(sensor);
            this.context.SaveChanges();

            return(sensor.Id);
        }
Exemplo n.º 2
0
 public DetailsViewModel(IRegisterableModel registration)
 {
     this.Url          = registration.Url;
     this.Name         = registration.Name;
     this.RefreshRate  = registration.RefreshRate;
     this.MinValue     = registration.MinValue;
     this.MaxValue     = registration.MaxValue;
     this.IsPublic     = registration.IsPublic;
     this.CurrentValue = registration.CurrentValue;
 }
Exemplo n.º 3
0
 public EditViewModel(Guid id, IRegisterableModel model)
 {
     this.Id           = id;
     this.Url          = model.Url;
     this.Name         = model.Name;
     this.RefreshRate  = model.RefreshRate;
     this.MinValue     = model.MinValue;
     this.MaxValue     = model.MaxValue;
     this.IsPublic     = model.IsPublic;
     this.CurrentValue = model.CurrentValue;
 }
Exemplo n.º 4
0
        public Guid UpdateSensor(Guid id, IRegisterableModel model)
        {
            var sensor = this.context.Sensors.Find(id);

            sensor.Url         = model.Url; //proverka dali se e smenil typa ako da create sensor i tiq danni
            sensor.Name        = model.Name;
            sensor.RefreshRate = model.RefreshRate;
            sensor.MinValue    = model.MinValue;
            sensor.MaxValue    = model.MaxValue;
            sensor.IsPublic    = model.IsPublic;
            this.context.SaveChanges();

            return(id);
        }