public Record Update(Record record)
 {
     _recordsValidator.ValidateAndThrow(record);
     _recordRepository.Edit(record);
     _context.SaveChanges();
     return(record);
 }
示例#2
0
        private void editBtn_Click(object sender, EventArgs e)
        {
            var selected = cyclingDiaryLv.SelectedIndices;

            if (selected.Count == 1)
            {
                var selectedIndex = selected[0];
                var item          = _recordRepo.GetForEdit(_recordIds[selectedIndex]);
                if (item == null)
                {
                    return;
                }
                var dialog = new RecordDialog(item, true);
                var result = dialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    _recordRepo.Edit(dialog.Item);
                    reloadAll();
                }
            }
        }
        public Result <DateRecord> Add(DateRecord record) => _repo.Add(record); // TODO: Add check for duplicate entry

        public Result <DateRecord> Edit(DateTime date, DateRecord newRecord) => _repo.Edit(Get(date).Data, newRecord);