Exemple #1
0
        public IActionResult Edit(int id, Author user)
        {
            var model = AuthorList.getInstance();

            model[id - 1] = user;
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        //----< deletes a story by id >-----------------------------

        /*
         * - note that Delete does not send back a view, but
         *   simply redirects back to the Index view, which
         *   will not show the deleted course because it was ...
         */
        public IActionResult Delete(int id)
        {
            var styList = AuthorList.getInstance();

            styList.delete(id - 1);
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        /// <summary>
        /// Загрузка авторов из БД
        /// </summary>
        /// <returns></returns>
        public AuthorList LoadAuthors()
        {
            var list = new AuthorList();

            if (server == null)
            {
                return(null);
            }

            try
            {
                var task = Task.Factory.StartNew(
                    () =>
                {
                    using (var documentStore = server.OpenClient())
                    {
                        var authors =
                            documentStore.Query <AuthorDb4o>(
                                x => x != null && !x.author.IsDeleted);
                        foreach (var author in authors)
                        {
                            author.author.Changed = false;
                            list.Add(author.author);
                        }
                    }
                });
                task.Wait();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка выборки данных из БД." + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(list);
        }
Exemple #4
0
        public IActionResult Edit(int id)
        {
            var userList = AuthorList.getInstance();
            var model    = userList[id - 1];

            return(View(model));
        }
Exemple #5
0
        // GET: /<controller>/
        public IActionResult Index()
        {
            var model = AuthorList.getInstance();
            IEnumerable <Author> userList = (IEnumerable <Author>)model.Authors;

            return(View(userList));
        }
 public MainForm()
 {
     InitializeComponent();
     _client            = new ApiClient(new Uri("http://localhost:8000"));
     _authorListControl = new AuthorList(_client);
     _booksListControl  = new BooksList(_client);
 }
        /// <summary>
        /// Загрузка авторов из БД
        /// </summary>
        /// <returns></returns>
        public AuthorList LoadAuthors()
        {
            if (ds != null)
            {
                ds.Dispose();
            }
            ds = new DataSet();
            AuthorList list = new AuthorList();

            using (SQLiteCommand mycommand = new SQLiteCommand(conn))
            {
                mycommand.CommandText = "select * from authors";
                da = new SQLiteDataAdapter();
                da.SelectCommand = mycommand;
                System.Data.SQLite.SQLiteCommandBuilder cb = new System.Data.SQLite.SQLiteCommandBuilder(da);
                da.Fill(ds, "authors");
                foreach (DataRow row in ds.Tables["authors"].Rows)
                {
                    var author = Xml2Author(row["author_xml"].ToString());
                    if (author != null)
                    {
                        author.Changed = false;
                        list.Add(author);
                    }
                }
            }
            return(list);
        }
Exemple #8
0
        private void btnAddAuthor_Click(object sender, EventArgs e)
        {
            string authorName = txtAuthorName.Text;

            // eger null veya boshdursa
            if (string.IsNullOrEmpty(authorName))
            {
                // ERROR mesajinin verilmersi
                MessageBox.Show("Author name is not valid", "Failed!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            // eger AuthorListde bu ad varsa
            if (AuthorList.ContainsAuthorName(authorName))
            {
                // ERROR mesaji verilir
                MessageBox.Show("Author name is duplicate", "Failed!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);

                return;
            }

            //user uyqun author adini daxil etdi ve bu addan yoxdur
            //bu halda yeni author-un AuthorList-e elave edilmesi
            AuthorList.AddAuthor(new Author(authorName));

            // Elave edildikden sonra setrin bosh gorsedilmesi
            txtAuthorName.Text = "";

            // Melumat mesajinin verilmesi
            MessageBox.Show("New author was successfully added", "Success!",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemple #9
0
        public IActionResult Create(int id, Author user)
        {
            var model = AuthorList.getInstance();

            model.add(user);
            return(RedirectToAction("Index"));
        }
Exemple #10
0
        //----< shows details for each story >----------------------
        public ViewResult Details(int id)
        {
            var model = AuthorList.getInstance();
            var user  = model[id - 1];

            return(View(user));
        }
Exemple #11
0
            public async Task <List <AuthorDto> > Handle(AuthorList request, CancellationToken cancellationToken)
            {
                var authors = await _contexto.BookAuthor.ToListAsync();

                var authorsDto = _mapper.Map <List <BookAuthor>, List <AuthorDto> >(authors);

                return(authorsDto);
            }
Exemple #12
0
            public async Task <List <Models.Application.AuthorDto> > Handle(AuthorList request, CancellationToken cancellationToken)
            {
                var records = await _context.Author.ToListAsync();

                var recordsDTO = _mapper.Map <List <Models.Author>, List <Models.Application.AuthorDto> >(records);

                return(recordsDTO);
            }
 private void SetAuthorList(object obj)
 {
     if (AuthorList == null)
     {
         AuthorList = new AuthorList();
     }
     AuthorView = AuthorList;
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            AuthorList.Add(DefaultAuthor);
            UseAuthor.IsChecked = true;

            KeywordTextBox.Text  = this.Keyword;
            UseKeyword.IsChecked = true;
        }
        public override global::System.Data.DataSet Clone()
        {
            AuthorList cln = ((AuthorList)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
Exemple #16
0
            public async Task <List <AuthorDTO> > Handle(AuthorList request, CancellationToken cancellationToken)
            {
                var bookAuthors = await _context.AuthorBook.ToListAsync();

                var authoresDTO = _mapper.Map <List <AuthorBook>, List <AuthorDTO> >(bookAuthors);

                return(authoresDTO);
            }
Exemple #17
0
        /// <summary>
        /// Очистка размеров и положений окон авторов от удаленных авторов
        /// и дефолтных размеров
        /// </summary>
        /// <param name="authors"></param>
        private void Cleaning(AuthorList authors)
        {
            try
            {
                string[] keys = new string[AdvancedWindowSettingDictionary.Keys.Count];
                AdvancedWindowSettingDictionary.Keys.CopyTo(keys, 0);
                foreach (string key in keys)
                {
                    if ((key != "Default") && (authors.FindAuthor(key) == null))
                    {
                        AdvancedWindowSettingDictionary.Remove(key);
                    }
                }
                Dictionary <string, AdvancedWindowSetting> copy =
                    new Dictionary <string, AdvancedWindowSetting>(AdvancedWindowSettingDictionary);
                AdvancedWindowSetting @default = AdvancedWindowSettingDictionary["Default"];
                foreach (KeyValuePair <string, AdvancedWindowSetting> pair in copy)
                {
                    if ((pair.Key != "Default") && (pair.Value.Size == @default.Size) &&
                        (pair.Value.HeightComment == @default.HeightComment))
                    {
                        AdvancedWindowSettingDictionary.Remove(pair.Key);
                    }
                }

                keys = new string[AuthorWindowSettingDictionary.Keys.Count];
                AuthorWindowSettingDictionary.Keys.CopyTo(keys, 0);
                foreach (string key in keys)
                {
                    try
                    {
                        if ((key != "Default") && (authors.FindAuthor(key) == null))
                        {
                            AuthorWindowSettingDictionary.Remove(key);
                        }
                    }
                    catch
                    {
                    }
                }
                var copy1 =
                    new Dictionary <string, AuthorWindowSetting>(AuthorWindowSettingDictionary);
                AuthorWindowSetting @default1 = AuthorWindowSettingDictionary["Default"];
                foreach (var pair in copy1)
                {
                    if ((pair.Key != "Default") && (pair.Value.Size == @default1.Size) &&
                        (pair.Value.Location == @default1.Location) &&
                        (pair.Value.HeightComment == @default1.HeightComment))
                    {
                        AuthorWindowSettingDictionary.Remove(pair.Key);
                    }
                }
            }
            catch
            {
            }
        }
Exemple #18
0
            public async Task <List <AuthorDto> > Handle(AuthorList request, CancellationToken cancellationToken)
            {
                var authors = await _context.AuthorBook.ToListAsync();

                //El formato que entra/El formato que sale/la data que se va a transformar:
                var authorsDto = _mapper.Map <List <AuthorBook>, List <AuthorDto> >(authors);

                return(authorsDto);
            }
Exemple #19
0
        public IActionResult Create(int id)
        {
            var userList = AuthorList.getInstance();

            var model = new Author();

            model.Id = userList.size() + 1;
            return(View(model));
        }
        public static void AddAuthor(Author author)
        {
            author.Id = AuthorList.Max(a => a.Id) + 1;
            AuthorList.Add(author);

            foreach (var book in author.Books)
            {
                AddBookForAuthor(author.Id, book);
            }
        }
Exemple #21
0
    protected void LoadDropDownList()
    {
        DataTable tbl = dc.GetAuthors();

        AuthorList.DataSource     = tbl;
        AuthorList.DataTextField  = "AuthorName";
        AuthorList.DataValueField = "AuthorKey";
        AuthorList.DataBind();
        AuthorList.Items.Insert(0, "Choose an Author");
    }
Exemple #22
0
        public void SaveToXML(AuthorList authors)
        {
            Cleaning(authors);
            var xs = new XmlSerializer(typeof(Setting));
            var sb = new StringBuilder();
            var w  = new StringWriter(sb, CultureInfo.InvariantCulture);

            xs.Serialize(w, this,
                         new XmlSerializerNamespaces(new[] { new XmlQualifiedName(string.Empty) }));
            File.WriteAllText(SettingFileName, sb.ToString());
        }
        private void SaveAuthor()
        {
            AuthorModel aut = new AuthorModel();

            aut.LastName     = CurrentAuthor.LastName;
            aut.FirstName    = CurrentAuthor.FirstName;
            aut.Birthdate    = CurrentAuthor.Birthdate;
            aut.Gender       = CurrentAuthor.Gender;
            aut.AuthorNumber = initial += 1;
            AuthorList.Add(aut);
            AV.Close();
        }
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            AuthorList ds = new AuthorList();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
 private void OkButton_Click(object sender, RoutedEventArgs e)
 {
     if ((UseKeyword.IsChecked ?? false) || (UseAuthor.IsChecked ?? false))
     {
         this.Keyword = string.IsNullOrWhiteSpace(KeywordTextBox.Text) ? "*" : KeywordTextBox.Text;
         if (AuthorList.Count == 0)
         {
             AuthorList.Add("*");
         }
         this.DialogResult = true;
     }
 }
Exemple #26
0
 public void Cancel()
 {
     Book.TENSACH = dataProvider.GetItem <SACH>(x => x.MASACH == Book.MASACH).TENSACH;
     Book.NAMXB   = dataProvider.GetItem <SACH>(x => x.MASACH == Book.MASACH).NAMXB;
     Book.ANHBIA  = dataProvider.GetItem <SACH>(x => x.MASACH == Book.MASACH).ANHBIA;
     Author       = AuthorList.FirstOrDefault(x => x.MATG == Book.MATG);
     Category     = CategoryList.FirstOrDefault(x => x.MATL == Book.MATL);
     Publisher    = PublisherList.FirstOrDefault(x => x.MANXB == Book.MANXB);
     if (string.IsNullOrEmpty(Book.ANHBIA) == true || File.Exists(Book.ANHBIA) == false)
     {
         Book.ANHBIA = @"/Resources/Images/Book/DefaultBook.jpg";
     }
 }
Exemple #27
0
    public void Load()
    {
        Debug.Log("CERN archive loading from path: " + jsonPath);
        if (loadImages)
        {
            images = LoadJson <ImageList>(jsonPath + "/files.json");
            images.PrepareData();
            Debug.Log("CERN Images loaded: " + images.items.Length);
        }
        if (loadRecords)
        {
            records = LoadJson <RecordList>(jsonPath + "/records.json");
            records.PrepareData();
            Debug.Log("CERN Records loaded: " + records.items.Length);
        }
        if (loadAuthors)
        {
            authors = LoadJson <AuthorList>(jsonPath + "/authors.json");
            authors.PrepareData();
            Debug.Log("CERN Authors loaded: " + authors.items.Length);
        }
        if (loadKeywords)
        {
            keywords = LoadJson <KeywordList>(jsonPath + "/keywords.json");
            keywords.PrepareData();
            Debug.Log("CERN Keywords loaded: " + keywords.items.Length);
        }
        if (loadSubjects)
        {
            subjects = LoadJson <SubjectList>(jsonPath + "/subjects.json");
            subjects.PrepareData();
            Debug.Log("CERN Subjects loaded: " + subjects.items.Length);
        }
        if (loadCopyrightHolders)
        {
            copyrightHolders = LoadJson <CopyrightHolderList>(jsonPath + "/copyright.json");
            copyrightHolders.PrepareData();
            Debug.Log("CERN CopyrightHolders loaded: " + copyrightHolders.items.Length);
        }
        if (loadCollections)
        {
            collections = LoadJson <CollectionList>(jsonPath + "/collections.json");
            collections.PrepareData();
            Debug.Log("CERN Collections loaded: " + collections.items.Length);
        }

        dataLoaded = true;
    }
        private async Task <Author> GetAuthor()
        {
            AuthorList authorList = null;

            try
            {
                authorList = await _bloggersPointService.RunGetJsonDataUsingIdTask <AuthorList>(AuthorDataResource, IdField, Post.UserId.ToString());
            }
            catch (Exception exception)
            {
                MessageService.ShowErrorMessage(Resources.ConnectivityErrorMessage);
                Log.Error(exception);
            }

            return(authorList?[0]);
        }
Exemple #29
0
 public BookDetailViewModel(DataProvider dataProvider, IEventAggregator eventAggregator) : base(dataProvider, eventAggregator)
 {
     AuthorList    = dataProvider.AuthorList;
     CategoryList  = dataProvider.CategoryList;
     PublisherList = dataProvider.PublisherList;
     Book          = dataProvider.SelectedBook;
     PublishRange  = dataProvider.LibraryRules.KHOANGCACHXB ?? 0;
     eventAggregator.Subscribe(this);
     Author     = AuthorList.FirstOrDefault(x => x.MATG == Book.MATG);
     Category   = CategoryList.FirstOrDefault(x => x.MATL == Book.MATL);
     Publisher  = PublisherList.FirstOrDefault(x => x.MANXB == Book.MANXB);
     DetailList = dataProvider.GetBookDetailList(x => x.MASACH == Book.MASACH);
     if (string.IsNullOrEmpty(Book.ANHBIA) == true || File.Exists(Book.ANHBIA) == false)
     {
         Book.ANHBIA = @"/Resources/Images/Book/DefaultBook.jpg";
     }
 }
Exemple #30
0
        /// <summary>
        /// Updates <see cref="AuthorList"/> with distinct sorted list of authors in <see cref="AllAssets"/>
        /// </summary>
        private void RefreshAuthorList()
        {
            List <AuthorDropdownViewModel> newAuthorList = new List <AuthorDropdownViewModel>();

            // use GroupBy to get count of assets per author
            foreach (IGrouping <string, AssetViewModel> author in AllAssets.GroupBy(a => a.Author))
            {
                newAuthorList.Add(new AuthorDropdownViewModel(author.Key, author.Count()));
            }

            newAuthorList = newAuthorList.OrderBy(a => a.Author).ToList();

            newAuthorList.Insert(0, new AuthorDropdownViewModel(defaultAuthorValue, 0));

            AuthorList = newAuthorList;

            //clear selection if selected author not in list
            if (AuthorList.Any(a => a.Author == AuthorToFilterBy.Author) == false)
            {
                AuthorToFilterBy = AuthorList[0];
            }
        }
Exemple #31
0
        /// <summary>
        /// Очистка размеров и положений окон авторов от удаленных авторов
        /// и дефолтных размеров
        /// </summary>
        /// <param name="authors"></param>
        private void Cleaning(AuthorList authors)
        {
            string[] keys = new string[AdvancedWindowSettingDictionary.Keys.Count];
            AdvancedWindowSettingDictionary.Keys.CopyTo(keys, 0);
            foreach (string key in keys)
            {
                if ((key != "Default") && (authors.FindAuthor(key) == null))
                    AdvancedWindowSettingDictionary.Remove(key);
            }
            Dictionary<string, AdvancedWindowSetting> copy =
                new Dictionary<string, AdvancedWindowSetting>(AdvancedWindowSettingDictionary);
            AdvancedWindowSetting @default = AdvancedWindowSettingDictionary["Default"];
            foreach (KeyValuePair<string, AdvancedWindowSetting> pair in copy)
            {
                if ((pair.Key != "Default") && (pair.Value.Size == @default.Size) &&
                    (pair.Value.HeightComment == @default.HeightComment))
                    AdvancedWindowSettingDictionary.Remove(pair.Key);
            }

            keys = new string[AuthorWindowSettingDictionary.Keys.Count];
            AuthorWindowSettingDictionary.Keys.CopyTo(keys, 0);
            foreach (string key in keys)
            {
                if ((key != "Default") && (authors.FindAuthor(key) == null))
                    AuthorWindowSettingDictionary.Remove(key);
            }
            var copy1 =
                new Dictionary<string, AuthorWindowSetting>(AuthorWindowSettingDictionary);
            AuthorWindowSetting @default1 = AuthorWindowSettingDictionary["Default"];
            foreach (var pair in copy1)
            {
                if ((pair.Key != "Default") && (pair.Value.Size == @default1.Size) &&
                    (pair.Value.Location == @default1.Location) && (pair.Value.HeightComment == @default1.HeightComment))
                    AuthorWindowSettingDictionary.Remove(pair.Key);
            }
        }
Exemple #32
0
 public void SaveToXML(AuthorList authors)
 {
     Cleaning(authors);
     var xs = new XmlSerializer(typeof (Setting));
     var sb = new StringBuilder();
     var w = new StringWriter(sb, CultureInfo.InvariantCulture);
     xs.Serialize(w, this,
                  new XmlSerializerNamespaces(new[] {new XmlQualifiedName(string.Empty)}));
     File.WriteAllText(SettingFileName, sb.ToString());
 }
 /// <summary>
 /// Загрузка авторов из БД
 /// </summary>
 /// <returns></returns>
 public AuthorList LoadAuthors()
 {
     if (ds != null) ds.Dispose();
     ds = new DataSet();
     AuthorList list = new AuthorList();
     using (SQLiteCommand mycommand = new SQLiteCommand(conn))
     {
         mycommand.CommandText = "select * from authors";
         da = new SQLiteDataAdapter();
         da.SelectCommand = mycommand;
         System.Data.SQLite.SQLiteCommandBuilder cb = new System.Data.SQLite.SQLiteCommandBuilder(da);
         da.Fill(ds, "authors");
         foreach (DataRow row in ds.Tables["authors"].Rows)
         {
             var author = Xml2Author(row["author_xml"].ToString());
             if (author != null)
             {
                 author.Changed = false;
                 list.Add(author);
             }
         }
     }
     return list;
 }
        /// <summary>
        /// Загрузка авторов из БД
        /// </summary>
        /// <returns></returns>
        public AuthorList LoadAuthors()
        {
            var list = new AuthorList();
            if (server == null) return null;

            try
            {
                var task = Task.Factory.StartNew(
                    () =>
                        {
                            using (var documentStore = server.OpenClient())
                            {
                                var authors =
                                    documentStore.Query<AuthorDb4o>(
                                    x => x != null && !x.author.IsDeleted);
                                foreach (var author in authors)
                                {
                                    author.author.Changed = false;
                                    list.Add(author.author);
                                }

                            }
                        });
            task.Wait();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ошибка выборки данных из БД." + ex.Message, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return list;
        }