private async void btnSave_Click(object sender, RoutedEventArgs e)
        {
            var tagDataService = new TagDataService(new EntityFramework.TimetableManagerDbContext());

            if (textBoxtag.Text != "")
            {
                if (isEditState)
                {
                    tag.TagName = textBoxtag.Text;
                    await tagDataService.UpdateTag(tag, tag.TagId);

                    isEditState = false;
                }
                else
                {
                    Tag newTag = new Tag
                    {
                        TagName = textBoxtag.Text
                    };
                    await tagDataService.AddTag(newTag);
                }
                textBoxtag.Clear();
            }
            else
            {
                MessageBox.Show("Insert a Tag!!");
            }

            TagDataList.Clear();
            _ = load();
        }
        private async Task LoadTagDataForEdit(int id)
        {
            TagDataService tagDataService = new TagDataService(new EntityFramework.TimetableManagerDbContext());

            tag = await tagDataService.GetTagById(id);

            textBoxtag.Text = tag.TagName;
            isEditState     = true;
        }
        private void DeleteButton_Click(object sender, RoutedEventArgs e)
        {
            Tag tag = (Tag)dataGridtag.SelectedItem;

            TagDataService tagDataService = new TagDataService(new EntityFramework.TimetableManagerDbContext());

            tagDataService.DeleteTag(tag.TagId).ContinueWith(result =>
            {
                MessageBox.Show("Deleted");
            });

            _ = TagDataList.Remove(tag);
        }
        public async Task load()
        {
            TagDataService tagDataService = new TagDataService(new EntityFramework.TimetableManagerDbContext());

            TagList = await tagDataService.GetTags();

            TagList.ForEach(e =>
            {
                Tag l     = new Tag();
                l.TagId   = e.TagId;
                l.TagName = e.TagName;
                TagDataList.Add(l);
            });
        }
Exemplo n.º 5
0
 public TagController(AppDBContext dbContext, ILoggerFactory loggerFactory)
 {
     this.logger      = loggerFactory.CreateLogger <TagController>();
     this.dataService = new TagDataService(dbContext, loggerFactory);
 }