Пример #1
0
        private void addAuthor_Click(object sender, EventArgs e)
        {
            AddAuthor addAuthorForm = new AddAuthor(this.currentUser);

            addAuthorForm.FormClosed += new FormClosedEventHandler(AddAuthorClosed);
            addAuthorForm.ShowDialog();
        }
Пример #2
0
        public ActionResult CreateAuthor(AddAuthor addAuthor)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    using (db)
                    {
                        var row = new Autorzy
                        {
                            imie          = addAuthor.imie,
                            nazwisko      = addAuthor.nazwisko,
                            dataUrodzenia = addAuthor.dataUrodzenia,
                        };

                        db.Autorzy.Add(row);
                        db.SaveChanges();
                        ViewBag.Message = "Autor dodany";
                    }
                }
                catch (Exception)
                { }
            }
            return(View(addAuthor));
        }
Пример #3
0
        public async Task Handle(AddAuthor message, CancellationToken cancellationToken)
        {
            AuthorEntityHandler.Add(message.Author);

            await Mediator.Send(new SaveChanges());

            await Mediator.Publish(new AuthorAdded(message.Author, message.UserId));
        }
Пример #4
0
        public ActionResult <Author> Post([FromBody] AddAuthor author)
        {
            var newAuthor = new Author
            {
                Age  = author.Age,
                Name = author.Name
            };

            _BooksDbContext.Authors.Add(newAuthor);
            _BooksDbContext.SaveChanges();

            return(newAuthor);
        }
Пример #5
0
 public Author Post([FromBody] AddAuthor authorItem)
 {
     try
     {
         var newAuthor = new Author
         {
             Name = authorItem.Name,
             Age  = authorItem.Age
         };
         _shopOnlineDbContext.Authors.Add(newAuthor);
         _shopOnlineDbContext.SaveChanges();
         return(newAuthor);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #6
0
        private void EditAuthorBtn_Click(object sender, RoutedEventArgs e)
        {
            AuthorViewModel authorVM = dataGrid.SelectedItem as AuthorViewModel;

            AddAuthor editAuthor = new AddAuthor(authorVM.Name, authorVM.SurName);

            if (editAuthor.ShowDialog().Value)
            {
                string name    = editAuthor.Name.Text;
                string surname = editAuthor.Surname.Text;

                if (authorVM != null && name != null && surname != null)
                {
                    Author author = authorController.GetById(authorVM.Id);
                    author.Name    = authorVM.Name = name;
                    author.SurName = authorVM.SurName = surname;
                    authorController.Edit(author);
                }
            }
        }
Пример #7
0
        private void AddAuthorBtn_Click(object sender, RoutedEventArgs e)
        {
            InitDataSource(ref authorItems, Mapper.AuthorsToAuthorViewModels, authorController.Get);

            AddAuthor addAuthor = new AddAuthor();

            if (addAuthor.ShowDialog().Value)
            {
                string name    = addAuthor.Name.Text;
                string surname = addAuthor.Surname.Text;

                if (name != null && surname != null)
                {
                    Author author = new Author(name, surname);
                    authorController.Add(author);
                    authorItems.Add(Mapper.AuthorToAuthorViewModel(author));
                    return;
                }
            }
        }
Пример #8
0
        private void ButAddAuthor_Click(object sender, EventArgs e)
        {
            AddAuthor _authorForm = new AddAuthor(this);

            _authorForm.ShowDialog();
            if (_authorForm.flag)
            {
                try
                {
                    _db.Authprs.Add(new Authors
                    {
                        FIO  = _authorForm.FIO,
                        Year = Int32.Parse(_authorForm.YearBorn)
                    });
                    _db.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
        private void addAuthorbtn_Click(object sender, EventArgs e)
        {
            try
            {
                AddAuthor addAuthor = new AddAuthor();
                addAuthor.ShowDialog();

                if (isChanged)
                {
                    InformationForm information = new InformationForm("An author is added.", "Info");
                    information.Show();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Something wrong!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                this.ViewAuthors_Load(sender, e);
            }
        }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            AddAuthor addAuthor = new AddAuthor();

            addAuthor.Show();
        }
Пример #11
0
 private void menu_addAuthor_Click(object sender, RoutedEventArgs e)
 {
     addAuthor = new AddAuthor();
     addAuthor.Show();
 }
Пример #12
0
        private void addAuthorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddAuthor addAuthorForm = new AddAuthor(this.currentUser);

            addAuthorForm.ShowDialog();
        }
        private void AppBarButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            AddAuthor a = new AddAuthor();

            a.ShowDialog();
        }
Пример #14
0
 private void newAuthor_Click(object sender, EventArgs e)
 {
     AddAuthor?.Invoke(sender, e);
 }