示例#1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Publisher,Title,Publication,Issue,Location,Publicationdate,Pages")] OfficialStatements officialStatements)
        {
            if (id != officialStatements.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(officialStatements);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OfficialStatementsExists(officialStatements.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            return(View(officialStatements));
        }
示例#2
0
        public async Task <IActionResult> Create([Bind("Id,Publisher,Title,Publication,Issue,Location,Publicationdate,Pages")] OfficialStatements officialStatements)
        {
            if (ModelState.IsValid)
            {
                _context.Add(officialStatements);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            return(View(officialStatements));
        }
示例#3
0
        public async Task <IActionResult> CreateAndConnect(string tablename, int tableid, int infotype, string currentpath, [Bind("Id,Publisher,Title,Publication,Issue,Location,Publicationdate,Pages")] OfficialStatements officialStatements)
        {
            int id = new int();

            String[] url = new String[4];

            if (ModelState.IsValid)
            {
                _context.Add(officialStatements);

                await _context.SaveChangesAsync();

                List <OfficialStatements> allentries = new List <OfficialStatements>();
                allentries = await _context.OfficialStatements.ToListAsync();

                foreach (OfficialStatements item in allentries)
                {
                    if (item == officialStatements)
                    {
                        id = officialStatements.Id;
                    }
                }
                var relation = new InfoSourcesInRelation {
                    Tablename = tablename, Tableid = tableid, Infotype = infotype, Infosourceid = id
                };
                _context.Add(relation);
                await _context.SaveChangesAsync();

                url = currentpath.Split('/');
                return(RedirectToAction(url[3], url[2], new { id = url[4] }));
                // return RedirectToAction("CreateAndConnect", "InfoSourcesInRelations", new { tablename = tablename, tableid = tableid, infotype = infotype, infosourceid = id, currentpath = currentpath });
            }
            return(View(officialStatements));
        }