Exemplo n.º 1
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Node node)
        {
            if (ModelState.IsValid)
            {
                _context.Add(node);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(node));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("AuthorID,Firstname,Lastname")] Author author)
        {
            if (ModelState.IsValid)
            {
                _context.Add(author);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(author));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,Title,Type,Year,Abstract")] Journal journal, IFormFile file1, IFormFile file2, Journal listBox)
        {
            var user = await _userManager.GetUserAsync(User);

            var author = _context.Author.Find(user.AuthorID);

            if (ModelState.IsValid)
            {
                if (!listBox.CoAuthor1.Equals("0"))
                {
                    journal.CoAuthor1 = await FindAuthorName(listBox.CoAuthor1);
                }

                if (!listBox.CoAuthor2.Equals("0"))
                {
                    journal.CoAuthor2 = await FindAuthorName(listBox.CoAuthor2);
                }

                if (listBox.Type.Equals("0"))
                {
                    journal.Type = await FindAuthorName(listBox.Type);
                }

                journal.AuthorID = user.AuthorID;

                if (file1 != null)
                {
                    journal.url = await Upload(file1);
                }

                if (file2 != null)
                {
                    journal.PeerUrl = await Upload(file2);
                }

                journal.ProofOfpeerReview = "This journal has not yet been peer reviewed";

                journal.Author = author;

                _context.Add(journal);
                await _context.SaveChangesAsync();

                author.Journals.Add(journal);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(journal));
        }