public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,FullAddress,MailingAddress,AsAboveAddress,EmailAddress,PhoneNumber,CitizenStatus,EmploymentStartDate,EmploymentType,PositionTitle,EmergencyContactName,EmergencyContactRelationship,EmergencyContactPhoneNumber,EmployeeSignature")] Todo todo) { if (id != todo.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(todo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoExists(todo.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(todo)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Address,Email,Comment")] Profile profile) { if (id != profile.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(profile); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!Exists(profile.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(profile)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Title,ReleaseDate,Genre,Price,Rating")] Movie movie) { if (id != movie.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(movie); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(movie.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(movie)); }
public async Task <IActionResult> ChangePassword() { using StreamReader reader = new StreamReader(Request.Body, Encoding.UTF8); dynamic parsedJson = JObject.Parse(await reader.ReadToEndAsync()); int tokenId = Int32.Parse(s: (string)parsedJson.tokenId); string resetCode = parsedJson.resetCode; string password = parsedJson.password; if (password.Length < MINIMUM_PASSWORD_LENGTH) { return(BadRequest("Password too short")); } MemberToken token = _context.MemberToken.Where(t => t.ID == tokenId) .First(); if (token == null) { throw new ArgumentException("Bad Token"); } Member owner = _context.Member.Where(u => u.ID == token.MemberID) .First(); if (resetCode != Member.getHash(token.TokenHash + owner.Password)) { throw new ArgumentException("Code Mismatch"); } owner.setPassword(password); _context.Update(owner); await _context.SaveChangesAsync(); return(Ok("Changed")); }
public IActionResult Edit(int id, Todo todo) { if (id != todo.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(todo); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TodoExists(todo.ID)) { return(NotFound()); } } return(RedirectToAction(nameof(Index))); } else { return(View(todo)); } }
public async Task <IActionResult> Edit(int id, [Bind("klient_id,imie,nazwisko,saldo")] Klient adres) { if (id != adres.klient_id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(adres); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KlientExists(adres.klient_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(adres)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Description,CreatedDate,Done")] Todo todo) { if (id != todo.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(todo); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TodoExists(todo.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(todo)); }
public async Task <IActionResult> Edit(int id, [Bind("DepartmentID,Name,PhoneNumber")] Department department) { if (id != department.DepartmentID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(department); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DepartmentExists(department.DepartmentID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(department)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Category,Engineer,Link")] Game game) { if (id != game.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(game); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GameExists(game.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(game)); }
public async Task <IActionResult> Edit(int id, [Bind("note_id,category,main_name,long_description,tags")] NoteSet adres) { if (id != adres.note_id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(adres); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KlientExists(adres.note_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(adres)); }
public async Task <IActionResult> Edit(int id, [Bind("adres_id,miast,ulicac,nrDomy,kodPocztowy,adres_klient_id")] Adres adres) { if (id != adres.adres_id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(adres); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AdresExists(adres.adres_id)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(adres)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Company,Price,CreatedDate")] Invoice invoice) { if (id != invoice.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(invoice); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InvoiceExists(invoice.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction("Index")); } return(View(invoice)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,FirstName,LastName,Degree,GameProject,SkillsLink,ProfileLink")] Member member) { if (id != member.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(member); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MemberExists(member.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(member)); }
public async Task <IActionResult> Edit(int id, [Bind("CardID,Name,Set,Id,Civilization,Rarity,Type,Cost,Text,Flavor,Illustrator,Race,Power,Races0,Races1,Civilizations0,Civilizations1")] DMCard dMCard) { if (id != dMCard.CardID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dMCard); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DMCardExists(dMCard.CardID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dMCard)); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Street,Housenumber,Zipcode,City,Phonenumber,Lat,Lng")] Store store) { if (id != store.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(store); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!StoreExists(store.ID)) { return(NotFound()); } } return(RedirectToAction(nameof(Index))); } return(View(store)); }
public async Task <IActionResult> Edit(int id, [Bind("EmployeeID,Name,DepartmentID,Email,PhoneNumber")] Employee employee) { if (id != employee.EmployeeID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(employee); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!EmployeeExists(employee.EmployeeID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["DepartmentID"] = new SelectList(_context.Department, "DepartmentID", "Name", employee.DepartmentID); return(View(employee)); }
public IActionResult UpdateProject([FromBody] ProjectModel request) { try { _context.Update(request); _context.SaveChanges(); return(Ok(request)); } catch (Exception error) { Console.WriteLine(error); return(BadRequest(SendResult.SendError("You don`t update Project info"))); } }
public Task UpdateProduct(Product Product) { var product = _context.Products.SingleOrDefault(x => x.Id == Product.Id); if (product == null) { throw new Exception($"Cannot find product with id: {Product.Id}"); } _context.Update(product); _context.SaveChanges(); return(Task.CompletedTask); }
/// <summary> /// obsługa zdarzenia podwójnego kliknięcia myszką na kontrolce ListView /// które wyzwala możliwość edycji rekordu występującego pod kursorem myszy /// </summary> /// <param name="sender">obiekt wysyłający zdarzenie</param> /// <param name="e">dodatkowe argumenty</param> private void personListView_MouseDoubleClick(object sender, MouseButtonEventArgs e) { var row = (DatabaseLibrary.Models.Person)personListView.SelectedItem; if (row != null) { var addWindow = new AddWindow(row.ID); if (addWindow.ShowDialog() == true) { var p = (from person in _context.Persons join contact in _context.Contacts on person.ID equals contact.PersonID where person.ID == row.ID select person).ToList().First(); var c = (from contact in _context.Contacts where contact.PersonID == row.ID select contact).ToList().First(); p.FirstName = addWindow.Firstname.Text.ToUpper(); p.LastName = addWindow.Surname.Text.ToUpper(); p.Age = Convert.ToInt32(addWindow.Age.Text); c.City = addWindow.City.Text.ToUpper(); c.Street = addWindow.Street.Text.ToUpper(); c.HomeNumber = addWindow.HomeNumer.Text.ToUpper(); c.PostCode = addWindow.PostCode.Text.ToUpper(); c.PostOffice = addWindow.PostOffice.Text.ToUpper(); c.Email = addWindow.Email.Text.ToUpper(); c.Phone = addWindow.Phone.Text.ToUpper(); p.Contact = c; // zapisa danych w bazie _context.Update(p); _context.SaveChanges(); // odświerzenie listy głównej personDataModel.Get(); } } }
public async Task <IActionResult> Edit(int id, [Bind("ID,PartName,PartType,SKU,Quantity,SuggestedQuantity,MinimumQuantity,UnitCost,Location,Status")] Inventory inventory) { Console.WriteLine("Inventory edit"); /*inventory.PartName = (string)ViewData["partName"]; * * * inventory.Quantity = (int)ViewData["quantity"]; * inventory.UnitCost = (decimal)ViewData["unitCost"];*/ Console.WriteLine("ID"); Console.WriteLine("PartName"); Console.WriteLine(inventory.PartName); Console.WriteLine("PartType"); Console.WriteLine("SKU"); Console.WriteLine("Quantity"); Console.WriteLine("SuggestedQuantity"); Console.WriteLine(inventory.SuggestedQuantity); Console.WriteLine("MinimumQuantity"); Console.WriteLine("UnitCost"); Console.WriteLine("Location"); Console.WriteLine("Status"); if (id != inventory.ID) { return(NotFound()); } if (ModelState.IsValid) { if (HttpContext.User.IsInRole("Admin") && inventory.Status == Inventory.InventoryStatus.Submitted) { inventory.Status = Inventory.InventoryStatus.Approved; } if (HttpContext.User.IsInRole("Admin")) { inventory.SuggestedQuantity = null; } try { _context.Update(inventory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!InventoryExists(inventory.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(inventory)); }
public async Task<IActionResult> AddToInventory(int id, [Bind("ID,Timestamp,OrderingStudent,RoboticsTeam,Vendor,PartName,SKU,Link,Quantity,Price,Justification,Status")] Order order) { Console.WriteLine("Add to Inventory Post"); if (id != order.ID) { Console.WriteLine("NOT FOUND"); return NotFound(); } Console.WriteLine("FOUND"); if (ModelState.IsValid) { order.Status = Order.OrderStatus.Added; try { _context.Update(order); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!OrderExists(order.ID)) { return NotFound(); } else { throw; } } Inventory inventory = new Inventory(); inventory.PartName = order.PartName; InventoryController ic = new InventoryController(_context); int partID = -1; partID = ic.queryForId(inventory.PartName); Console.WriteLine("PART ID"); Console.WriteLine(partID); if(partID == -1) { inventory.SKU = order.SKU; inventory.UnitCost = order.Price; inventory.Quantity = order.Quantity; inventory.Status = Inventory.InventoryStatus.Approved; _context.Add(inventory); await _context.SaveChangesAsync(); } else { Console.WriteLine("UPDATING EXISTING ITEM"); var updatedInventory = await _context.Inventory.FindAsync(partID); Console.WriteLine(updatedInventory.Quantity); Console.WriteLine(order.Quantity); updatedInventory.Quantity += order.Quantity; Console.WriteLine(updatedInventory.Quantity); _context.Update(updatedInventory); await _context.SaveChangesAsync(); } return RedirectToAction(nameof(Index)); } return View(order); }