Пример #1
0
        public ItemsLogLatestAIOViewModel GeItemsLogLatest(int itemId)
        {
            ItemsLogLatestAIOViewModel result = null;

            ItemsLogLatest current = Entities.ItemsLogLatests.FirstOrDefault(x => x.ItemId == itemId);

            if (current == null)
            {
                return(null);
            }

            result = new ItemsLogLatestAIOViewModel(current);

            return(result);
        }
Пример #2
0
        private void SaveValueInItemsLogLatest(string value)
        {
            ItemsLogLatest itemsLogLatest = null;

            if (Entities.ItemsLogLatests.Any(x => x.ItemId == this.ItemId))
            {
                itemsLogLatest       = Entities.ItemsLogLatests.FirstOrDefault(x => x.ItemId == this.ItemId);
                itemsLogLatest.Time  = DateTime.Now;
                itemsLogLatest.Value = value;
            }
            else
            {
                itemsLogLatest        = new ItemsLogLatest();
                itemsLogLatest.ItemId = this.ItemId;
                itemsLogLatest.Time   = DateTime.Now;
                itemsLogLatest.Value  = value;
                Entities.ItemsLogLatests.Add(itemsLogLatest);
            }

            Entities.SaveChanges();

            this.LastItemLogLatest = itemsLogLatest;
        }