Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Description,Language,Types")] TypesTrans typesTrans)
        {
            if (id != typesTrans.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typesTrans);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypesTransExists(typesTrans.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["Language"] = new SelectList(_context.Languages, "Id", "Code", typesTrans.Language);
            ViewData["Types"]    = new SelectList(_context.Types, "Id", "Id", typesTrans.Types);
            return(View(typesTrans));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(int Types, [Bind("Id,Name,Description,Language,Types")] TypesTrans typesTrans)
        {
            if (ModelState.IsValid)
            {
                if (Types == 0)
                {
                    Types entry = new Types(); _context.Add(entry); typesTrans.Types = entry.Id;
                }

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

                return(RedirectToAction("Index"));
            }
            ViewData["Language"] = new SelectList(_context.Languages, "Id", "Code", typesTrans.Language);
            ViewData["Types"]    = new SelectList(_context.Types, "Id", "Id", typesTrans.Types);
            return(View(typesTrans));
        }