Beispiel #1
0
 public void ShowAllAuthorsMethod()
 {
     using (Model1 context = new Model1())
     {
         foreach (Author a in context.Authors)
         {
             AllAuthors.Add(new AuthorViewModel()
             {
                 SecondName = a.SecondName, FirstName = a.FirstName, FatherName = a.FatherName
             });
         }
     }
 }
Beispiel #2
0
        public void AddAuthorMethod()
        {
            AllAuthors.Add(SelectedAuthor);
            Author OneAuthor = new Author();

            OneAuthor.FatherName = SelectedAuthor.FatherName;
            OneAuthor.FirstName  = SelectedAuthor.FirstName;
            OneAuthor.SecondName = SelectedAuthor.SecondName;
            using (Model1 context = new Model1())
            {
                context.Authors.Add(OneAuthor);
                context.SaveChanges();
            }
        }
 public void SetAuthorList(List <AuthorBO> authors)
 {
     if (AllAuthors == null)
     {
         AllAuthors = new List <SelectListItem>();
     }
     else
     {
         AllAuthors.Clear();
     }
     foreach (AuthorBO author in authors)
     {
         SelectListItem item = new SelectListItem();
         item.Value = author.AuthorID.ToString();
         item.Text  = author.Name;
         AllAuthors.Add(item);
     }
 }