コード例 #1
0
        public async Task <ActionResult <Pertence> > Create([FromBody] Pertence pertence)
        {
            if (ModelState.IsValid)
            {
                _context.Pertence.Add(pertence);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(pertence);
        }
コード例 #2
0
        // GET: Pertence/Edit/5
        public ActionResult Edit(int id)
        {
            ViewBag.title_page = "Pertence";
            ViewBag.path       = "Início / Pertence / Editar";

            IEnumerable <Tipopertence> listaTipoPertence = _tipopertenceService.ObterTodos();

            ViewBag.idTipoPertence = new SelectList(listaTipoPertence, "IdTipoPertence", "Nome", null);

            Pertence      pertence      = _pertenceService.Obter(id);
            PertenceModel pertenceModel = _mapper.Map <PertenceModel>(pertence);

            return(View(pertenceModel));
        }
コード例 #3
0
 public async Task <ActionResult <Pertence> > Edit([FromBody] Pertence pertence)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(pertence);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             return(NotFound());
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(pertence);
 }
コード例 #4
0
 public void Atualizar(Pertence pertence)
 {
     _context.Update(pertence);
     _context.SaveChanges();
 }
コード例 #5
0
 public int Inserir(Pertence pertence)
 {
     _context.Add(pertence);
     _context.SaveChanges();
     return(pertence.IdPertence);
 }