예제 #1
0
        public async Task <IActionResult> Edit(int Idratio, int Idsector, [Bind("Idratio,Idsector,Valorratiob")] Ratiobasesector ratiobasesector)
        {
            if (Idratio != ratiobasesector.Idratio || Idsector != ratiobasesector.Idsector)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(ratiobasesector);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RatiobasesectorExists(ratiobasesector.Idratio))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Idratio"]  = new SelectList(_context.Ratio, "Idratio", "Nombreratiob", ratiobasesector.Idratio);
            ViewData["Idsector"] = new SelectList(_context.Sector, "Idsector", "Nomsector", ratiobasesector.Idsector);
            return(View(ratiobasesector));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Idratio,Idsector,Valorratiob")] Ratiobasesector ratiobasesector)
        {
            if (ModelState.IsValid)
            {
                //_context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[RATIOBASESECTOR] ON");
                //_context.Database.ExecuteSqlCommand("INSERT INTO RATIOBASESECTOR (Idratio, Idsector, Valorratiob) VALUES ("
                //    + ratiobasesector.Idratio + ", "
                //    + ratiobasesector.Idsector + ", "
                //    + ratiobasesector.Valorratiob + ");");
                _context.Add(ratiobasesector);
                await _context.SaveChangesAsync();

                //_context.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [dbo].[RATIOBASESECTOR] OFF");
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["Idratio"]  = new SelectList(_context.Ratio, "Idratio", "Nombreratiob", ratiobasesector.Idratio);
            ViewData["Idsector"] = new SelectList(_context.Sector, "Idsector", "Nomsector", ratiobasesector.Idsector);
            return(View(ratiobasesector));
        }