예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Sobrenome,TurmaId")] Aluno aluno)
        {
            if (id != aluno.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(aluno);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AlunoExists(aluno.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(aluno));
        }
예제 #2
0
        public async Task <IActionResult> Edit(string id, [Bind("ID,Name,Email,PhoneNumber")] Dealership dealership)
        {
            if (id != dealership.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dealership);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DealershipExists(dealership.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dealership));
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Make,Model,Year,VIN,Colour,DealershipID")] Car car)
        {
            if (id != car.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(car);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CarExists(car.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(car));
        }
예제 #4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome,Sobrenome,Email,DataDeNascimento")] Autor autor)
        {
            if (id != autor.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(autor);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AutorExists(autor.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(autor));
        }
예제 #5
0
        public async Task <IActionResult> Edit(string id, [Bind("FirstName,LastName,UserName,Email,Company,Position,BirthDate")] Member member)
        {
            if (id != member.UserName)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(member);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MemberExists(member.UserName))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(member));
        }
예제 #6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Nome")] Turma turma)
        {
            if (id != turma.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(turma);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TurmaExists(turma.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(turma));
        }
예제 #7
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Titulo,ISBN,Ano,AutorId")] Livro livro)
        {
            if (id != livro.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(livro);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LivroExists(livro.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(livro));
        }
예제 #8
0
        //[ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int id, [FromBody] userLogin userLogin)
        {
            if (id != userLogin.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(userLogin);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!userLoginExists(userLogin.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(userLogin));
        }
예제 #9
0
        private string setToken(userLogin user)
        {
            user.Token = Guid.NewGuid().ToString();

            _context.Update(user);
            _context.SaveChanges();
            return(user.Token);
        }
        public void Update(TodoItem todoItem)
        {
            var todoItemUpdate = GetById(todoItem.Id);

            todoItemUpdate.Name       = todoItem.Name;
            todoItemUpdate.IsComplete = todoItem.IsComplete;
            _context.Update(todoItemUpdate);
            _context.SaveChanges();
        }
예제 #11
0
        public IActionResult Put(Category category)
        {
            using var context = new WebApiContext();
            //var response = context.Categories.Find(category.Id);
            var response = context.Find <Category>(category.Id);

            if (response == null)
            {
                return(NotFound());
            }

            response.Name = category.Name;
            context.Update(response);
            context.SaveChanges();
            return(NoContent());
        }
예제 #12
0
        public async Task <ActionResult <User> > Put(User user)
        {
            if (user == null)
            {
                return(BadRequest());
            }
            if (!_context.Users.Any(x => x.Id == user.Id))
            {
                return(NotFound());
            }

            _context.Update(user);
            await _context.SaveChangesAsync();

            return(Ok(user));
        }
예제 #13
0
        public async Task <IActionResult> Put(Ticket ticket)
        {
            if (ticket == null)
            {
                return(BadRequest());
            }
            if (!_context.Tickets.Any(x => x.Id == ticket.Id))
            {
                return(NotFound());
            }

            _context.Update(ticket);
            await _context.SaveChangesAsync();

            return(Ok(ticket));
        }
예제 #14
0
        //public IEnumerable<Pessoa> List(Guid id, string nome, string sobreNome, string rg)
        //{
        //    var pessoas = _context.Pessoa.AsQueryable();

        //    if (id != Guid.Empty && id != null)
        //        pessoas = pessoas.Where(x => x.Id == id);
        //    if (string.IsNullOrWhiteSpace(nome) == false)
        //        pessoas = pessoas.Where(x => x.Nome == nome);
        //    if (string.IsNullOrWhiteSpace(sobreNome) == false)
        //        pessoas = pessoas.Where(x => x.Sobrenome == sobreNome);
        //    if (string.IsNullOrWhiteSpace(rg) == false)
        //        pessoas = pessoas.Where(x => x.Rg == rg);

        //    return pessoas.AsNoTracking().ToList();
        //}

        public Task Update(Pet pet)
        {
            _context.Update(pet);
            return(_context.SaveChangesAsync());
        }