示例#1
0
 public DiaryItemViewModel()
 {
     DiaryItem = new DiaryItem()
     {
         Time = DateTime.Now
     };
 }
示例#2
0
 public ForecastViewModel()
 {
     DiaryItem = new DiaryItem()
     {
         Time = DateTime.Now
     };
 }
示例#3
0
        private async Task AddItemsToContainerAsync()
        {
            DiaryItem diaryItem = new DiaryItem
            {
                UserName  = "******",
                Note      = "This is a note from the program",
                TimeStamp = DateTime.UtcNow.ToString(),
                Rating    = "3",
                Id        = Guid.NewGuid().ToString()
            };


            try
            {
                // Read the item to see if it exists.
                ItemResponse <DiaryItem> diaryItemResponse = await this.container.ReadItemAsync <DiaryItem>(diaryItem.Id, new PartitionKey(diaryItem.UserName));

                Console.WriteLine("Item in database with id: {0} already exists\n", diaryItemResponse.Resource.Id);
            }
            catch (CosmosException ex) when(ex.StatusCode == HttpStatusCode.NotFound)
            {
                ItemResponse <DiaryItem> diaryItemResponse = await this.container.CreateItemAsync <DiaryItem>(diaryItem, new PartitionKey(diaryItem.UserName));

                Console.WriteLine("Created item in database with id: {0} Operation consumed {1} RUs.\n", diaryItemResponse.Resource.Id, diaryItemResponse.RequestCharge);
            }
        }
示例#4
0
 public DiaryItemViewModel(Page page)
 {
     Page      = page;
     DiaryItem = new DiaryItem()
     {
         Time = DateTime.Now
     };
 }
示例#5
0
 private void Update()
 {
     if (notes[notes.Count - 1] != topDiaryItem)
     {
         updateLog();
         topDiaryItem = notes[notes.Count - 1];
     }
 }
示例#6
0
        public static DiaryItem CreateDiaryItem(Car car = null, int mileage = 1000, DateTime?timestamp = null)
        {
            car ??= VehiclesTestData.CreateCar();
            timestamp ??= DateTime.Now;
            var valid = new DiaryItem(car, mileage, timestamp.Value);

            /* do magic here with reflection to modify object however you want */

            return(valid);
        }
示例#7
0
 public void addElement(DiaryItem noteDiary)
 {
     if (notes == null)
     {
         notes = new List <DiaryItem>();
     }
     notes.Add(noteDiary);
     if (notes.Count > 30)
     {
         notes.RemoveAt(0);
     }
 }
示例#8
0
        public object Clone()
        {
            var diaryItem = (DiaryItem)DiaryItem.Clone();

            return(new DiaryItemViewModel
            {
                DiaryItem = diaryItem,
                Navigation = this.Navigation,
                Page = this.Page,
                DiaryListViewModel = this.DiaryListViewModel
            });
        }
        public void Execute(CreateItemCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (_repository == null)
            {
                throw new InvalidOperationException("Repository is not initialized.");
            }
            var aggregate = new DiaryItem(command.Id, command.Title, command.Description, command.From, command.To);

            aggregate.Version = -1;
            _repository.Save(aggregate, aggregate.Version);
        }
示例#10
0
    private void startDiaryLog(string logJorneyID)
    {
        //пытаемся получить обьект jorney от контроллера
        jorney = JorneysController.getJorneyComponentById(logJorneyID);
        //если обьект был найден - инициализируем для него интерфейс
        if (jorney != null)
        {
            createNotesGUI(jorney.values.diary.notes.Count);

            notes        = jorney.values.diary.notes;
            topDiaryItem = notes[notes.Count - 1];

            updateLog();
        }
    }
        public void Execute(CreateItemCommand command)
        {
            if (command == null)
            {
                throw new Exception();
            }
            if (_repository == null)
            {
                throw new Exception();
            }
            var aggregate = new DiaryItem(command.Id, command.Title, command.Description, command.From, command.To);

            aggregate.Version = -1;
            _repository.Save(aggregate, aggregate.Version);
        }
        public Task <string> Handle(CreateItemCommand command, CancellationToken token)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }

            if (_repository == null)
            {
                throw new InvalidOperationException("Repository is not initialized.");
            }

            var aggregate = new DiaryItem(command.Id, command.Title, command.From, command.To, command.Description);

            aggregate.Version = -1;
            _repository.Save(aggregate, aggregate.Version);
            return(Task.FromResult("Ok"));
        }
示例#13
0
        public async Task CreateDiaryItem(DiaryItem item)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(item.Title) || string.IsNullOrWhiteSpace(item.Description))
                {
                    throw new Exception("Diary title and description required.");
                }

                var queryResult = await _connection.InsertAsync(item).ConfigureAwait(continueOnCapturedContext: false);

                StatusMessage = $"{queryResult} item added [Title: {item.Title}]";
            }
            catch (Exception ex)
            {
                StatusMessage = $"Failed to create item. Error: {ex.Message}";
            }
        }
示例#14
0
        public DiaryItem Diary([System.Web.Http.FromBody] DiaryItem diaryItem)
        {
            var diarys = new DiaryManager();

            return(diarys.Add(diaryItem));
        }
示例#15
0
 public DiaryItemViewModel(Page page, DiaryItem diaryItem)
 {
     Page      = page;
     DiaryItem = diaryItem;
 }
        public DiaryItem Update([FromBody] DiaryItem item)
        {
            var m = new DiaryManager();

            return(m.Update(item));
        }
        public void Delete([FromBody] DiaryItem item)
        {
            var m = new DiaryManager();

            m.Delete(item.Id);
        }
示例#18
0
 public DiaryEvent(DiaryItem item)
 {
     throw new NotImplementedException();
 }
示例#19
0
 public void Init(DiaryItem diaryItem = null)
 {
     _diaryItem      = diaryItem == null ? new DiaryItem() : diaryItem;
     _diaryItem.Date = _dateProvider.Today();
 }
示例#20
0
 public void setContent(DiaryItem _logContent)
 {
     textRef = GetComponentInChildren <TMP_Text>();
     textRef.SetText(_logContent.text);
 }