public async Task <IActionResult> Edit(int id, [Bind("Id,Ip,Name,Age")] info info) { if (id != info.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(info); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!infoExists(info.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(info)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Ten")] TheLoai theLoai) { if (id != theLoai.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(theLoai); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TheLoaiExists(theLoai.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(theLoai)); }
public async Task <IActionResult> Edit(int id, [Bind("categoryID,categoryName,Quantity")] Category category) { if (id != category.categoryID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(category); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CategoryExists(category.categoryID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(category)); }
public async Task <IActionResult> Edit(int id, [Bind("productID,Name,Price,Image,productDate,categoryID")] Product product) { if (id != product.productID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(product); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductExists(product.productID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["categoryID"] = new SelectList(_context.Items, "categoryID", "categoryName", product.categoryID); return(View(product)); }
public async Task <IActionResult> Edit(int id, [Bind("userID,FullName,DateOfBirth,cardID")] User user) { if (id != user.userID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.userID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["cardID"] = new SelectList(_context.Cards, "CardID", "type", user.cardID); return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("id,username,passwordHash,salt,role")] User user) { if (id != user.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(user); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserExists(user.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(user)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,userID,productID")] Basket basket) { if (id != basket.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(basket); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BasketExists(basket.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["productID"] = new SelectList(_context.Products, "productID", "Name", basket.productID); ViewData["userID"] = new SelectList(_context.Users, "userID", "FullName", basket.userID); return(View(basket)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,DeCauHoi,CauTraLoi1,CauTraLoi2,CauTraLoi3,CauTraLoi4,DapAn,TheLoaiId")] CauHoi cauHoi) { if (id != cauHoi.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cauHoi); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CauHoiExists(cauHoi.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TheLoaiId"] = new SelectList(_context.TheLoai, "Id", "Id", cauHoi.TheLoaiId); return(View(cauHoi)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Ten,CauHoiThiId,NguoiDungId")] Thi thi) { if (id != thi.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(thi); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ThiExists(thi.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["NguoiDungId"] = new SelectList(_context.NguoiDungs, "Id", "DiaChi", thi.NguoiDungId); return(View(thi)); }
public async Task <IActionResult> Edit(int id, [Bind("id,name,contactNumber,category,text,date,status,operatorName,comment")] Request request) { if (id != request.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(request); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestExists(request.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(request)); }
public async Task <IActionResult> Edit(int id, [Bind("AlunoId,Nome,Email,RA,DataCadastro")] Aluno aluno) { if (id != aluno.AlunoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(aluno); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AlunoExists(aluno.AlunoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(aluno)); }
public async Task <IActionResult> Edit(int id, [Bind("BlocoId,Nome,Descricao")] Bloco bloco) { if (id != bloco.BlocoId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bloco); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BlocoExists(bloco.BlocoId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bloco)); }
public async Task <IActionResult> Edit(int id, [Bind("ReservaId,Nome,SalaId,DataInicio,DataFim,AlunoId")] Models.Reserva reserva) { if (id != reserva.ReservaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(reserva); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReservaExists(reserva.ReservaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AlunoId"] = new SelectList(_context.Aluno, "AlunoId", "AlunoId", reserva.AlunoId); ViewData["SalaId"] = new SelectList(_context.Sala, "SalaId", "SalaId", reserva.SalaId); return(View(reserva)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Email,MatKhau,DiaChi")] NguoiDung nguoiDung) { if (id != nguoiDung.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(nguoiDung); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NguoiDungExists(nguoiDung.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(nguoiDung)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Ten,ThiId")] Diem diem) { if (id != diem.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(diem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DiemExists(diem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ThiId"] = new SelectList(_context.This, "Id", "Ten", diem.ThiId); return(View(diem)); }
public async Task <IActionResult> Edit(int id, [Bind("CauHoiId,ThiId,Ten")] CauHoiThi cauHoiThi) { if (id != cauHoiThi.CauHoiId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(cauHoiThi); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CauHoiThiExists(cauHoiThi.CauHoiId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CauHoiId"] = new SelectList(_context.CauHoi, "Id", "Id", cauHoiThi.CauHoiId); ViewData["ThiId"] = new SelectList(_context.This, "Id", "Ten", cauHoiThi.ThiId); return(View(cauHoiThi)); }
public async Task <IActionResult> Edit(int id, [Bind("userID,AddressLine1,City,State,Country")] Address address) { if (id != address.userID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(address); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AddressExists(address.userID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["userID"] = new SelectList(_context.Users, "userID", "FullName", address.userID); return(View(address)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Artist,FileName,StartTime,StopTime,Position")] Song song) { if (id != song.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(song); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SongExists(song.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(song)); }
public async Task <IActionResult> Edit(int id, [Bind("CardID,type")] DiscountCard discountCard) { if (id != discountCard.CardID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(discountCard); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DiscountCardExists(discountCard.CardID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(discountCard)); }
private User UpdateAndSaveUser(AppDataContext context, User user) { var result = context.Update(user); context.SaveChanges(); return(result.Entity); }
public async Task <IActionResult> Edit(int id, [Bind("id,name")] RequestCategory requestCategory) { if (id != requestCategory.id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(requestCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RequestCategoryExists(requestCategory.id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(requestCategory)); }
public async Task <IActionResult> Edit(int id, [Bind("SalaId,Nome,BlocoId,Disponivel")] Sala sala) { if (id != sala.SalaId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(sala); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SalaExists(sala.SalaId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["BlocoId"] = new SelectList(_context.Bloco, "BlocoId", "BlocoId", sala.BlocoId); return(View(sala)); }
public void Update(TEntity entity, int userId) { var entityEntry = _dbContext.Update(entity); entityEntry.Property("LastModifiedBy").CurrentValue = userId; SaveChanges(userId); }
public async Task <IActionResult> Edit(TodoList todoList) { if (ModelState.IsValid) { _db.Update(todoList); await _db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(todoList)); }
public async Task <IActionResult> MarkAsDone(Guid id) { var todo = await _db.TodoItems.SingleAsync(m => m.Id == id); if (todo == null) { return(HttpNotFound()); } todo.Done = true; _db.Update(todo); await _db.SaveChangesAsync(); return(RedirectToAction("Index", new { Id = todo.TodoListId })); }
public ColidEntrySubscription AppendColidEntrySubscriptionToUser(ColidEntrySubscription ce, User user) { using var context = new AppDataContext(_dbOptions); var dbSubscription = context.ColidEntrySubscriptions.Find(ce.Id); if (dbSubscription == null) { throw new EntityNotFoundException("Doesn't exist."); } dbSubscription.User = user; var result = context.Update(dbSubscription); context.SaveChanges(); return(result.Entity); }
public async Task <IActionResult> Edit(int id, TaxiEntity taxiEntity) { if (id != taxiEntity.Id) { return(NotFound()); } if (ModelState.IsValid) { try { taxiEntity.Plaque = taxiEntity.Plaque.ToUpper(); _context.Update(taxiEntity); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } catch (DbUpdateConcurrencyException) { if (!TaxiEntityExists(taxiEntity.Id)) { return(NotFound()); } else { throw; } } catch (Exception ex) { if (ex.InnerException.Message.Contains("duplicate")) { ModelState.AddModelError(string.Empty, "Already exist a Taxi with the same Plaque."); } else { ModelState.AddModelError(string.Empty, ex.InnerException.Message); } } } return(View(taxiEntity)); }
public void CreateOrUpdateUserInfo(string uid, string latitude, string longitude) { if (CheckUIDisExist(uid)) { var u = dataContext.Users.Where(x => x.UID == uid).First(); u.Latitude = "43434"; u.Longitude = "54535"; dataContext.Update(u); dataContext.SaveChanges(); } else { User u = new User() { UID = uid, Latitude = latitude, Longitude = longitude }; dataContext.Users.Add(u); dataContext.SaveChanges(); } }
public void Atualizar(Cliente cliente) { _db.Update(cliente); _db.SaveChanges(); }
public void Atualizar(Colaborador cliente) { _db.Update(cliente); _db.SaveChanges(); }