Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ContratoPromoTelemovelId,ContratoId,PromoTelemovelId,DataInicio,DataFim")] ContratoPromoTelemovel contratoPromoTelemovel)
        {
            if (id != contratoPromoTelemovel.ContratoPromoTelemovelId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(contratoPromoTelemovel);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ContratoPromoTelemovelExists(contratoPromoTelemovel.ContratoPromoTelemovelId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContratoId"]       = new SelectList(_context.Contratos, "ContratoId", "ContratoId", contratoPromoTelemovel.ContratoId);
            ViewData["PromoTelemovelId"] = new SelectList(_context.PromoTelemovel, "PromoTelemovelId", "PromoTelemovelId", contratoPromoTelemovel.PromoTelemovelId);
            return(View(contratoPromoTelemovel));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("ContratoPromoTelemovelId,ContratoId,PromoTelemovelId,DataInicio,DataFim")] ContratoPromoTelemovel contratoPromoTelemovel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(contratoPromoTelemovel);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ContratoId"]       = new SelectList(_context.Contratos, "ContratoId", "ContratoId", contratoPromoTelemovel.ContratoId);
            ViewData["PromoTelemovelId"] = new SelectList(_context.PromoTelemovel, "PromoTelemovelId", "PromoTelemovelId", contratoPromoTelemovel.PromoTelemovelId);
            return(View(contratoPromoTelemovel));
        }