Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Cpf,Nome")] Cotista cotista)
        {
            if (id != cotista.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(cotista);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CotistaExists(cotista.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(cotista));
        }
Exemple #2
0
        public async Task <IActionResult> PutCotista([FromRoute] int id, [FromBody] Cotista cotista)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != cotista.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cotista).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CotistaExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        public async Task <IActionResult> Create([Bind("Id,Cpf,Nome")] Cotista cotista)
        {
            if (ModelState.IsValid)
            {
                _context.Add(cotista);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(cotista));
        }
Exemple #4
0
        public async Task <IActionResult> PostCotista([FromBody] Cotista cotista)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Cotistas.Add(cotista);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetCotista", new { id = cotista.Id }, cotista));
        }