public IHttpActionResult PutIssue(int id, Issue issue) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != issue.issueID) { return(BadRequest()); } db.Entry(issue).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!IssueExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private void Button_Click(object sender, RoutedEventArgs e) { using (var db = new dat154_18_2Entities()) { string name = textbox1.Text; Customer kunde = new Customer { navn = name, passord = "1234" }; db.Customer.Add(kunde); db.SaveChanges(); db.Customer.Load(); DateTime from = (DateTime)FirstCal.SelectedDate; DateTime to = (DateTime)SecondCal.SelectedDate; Booking book = new Booking { checkinDate = from, checkoutDate = to, customerID = kunde.customerID, roomtype = (int)room.roomType }; db.Booking.Add(book); db.SaveChanges(); db.Booking.Load(); MessageBoxResult m = MessageBox.Show("Bestilling fullført. \n KundeNr " + kunde.customerID + "\n Passord " + kunde.passord + "\n BookingID " + book.bookingID + " \n ", "Confirmation", MessageBoxButton.OK, MessageBoxImage.Information); if (m == MessageBoxResult.OK) { this.Close(); } } }
private void slettbutton_Click(object sender, RoutedEventArgs e) { if (resList.SelectedItem != null) { db.Booking.Remove((Booking)resList.SelectedItem); db.SaveChanges(); } }
public ActionResult Create([Bind(Include = "customerID,navn,passord")] Customer customer) { if (ModelState.IsValid) { db.Customer.Add(customer); db.SaveChanges(); return(RedirectToAction("YourAccount", "Home", customer)); } return(View(customer)); }
private void Button_Click(object sender, RoutedEventArgs e) { this.bk.roomtype = roomtype.SelectedIndex + 1; this.bk.checkinDate = (DateTime)innkalender.SelectedDate; this.bk.checkoutDate = (DateTime)utkalender.SelectedDate; db.SaveChanges(); delegatClass.delegat.Invoke(); //fyr delegat this.Close(); }
private void OpprettSak_Click(object sender, RoutedEventArgs e) { int typesak = ComboSak.SelectedIndex; string description = Beskrivelse.Text; string note1 = Tilleggsinformasjon.Text; db.Issue.Add(new Issue { room = rom.roomID, issueType = typesak, issueDescription = description, note = note1, status = 0, timeIssued = DateTime.Now }); db.SaveChanges(); this.Close(); }
public MainWindow() { InitializeComponent(); db = new dat154_18_2Entities(); delegatClass.delegat += updateView; //var room1 = new Room { roomType = 1, vasket = false, opptatt = false }; //db.Room.Add(room1); db.SaveChanges(); db.Room.Load(); romList.DataContext = romtypeCombo.DataContext = db.Room.Local; romtypeCombo.SelectedIndex = 0; }
private void Button_Click(object sender, RoutedEventArgs e) { if (romList.SelectedItem != null) { { Room selected = (Room)romList.SelectedItem; Room rom = db.Room.Where(r => r.roomID == selected.roomID).First(); if (((Button)sender).Name.Equals("VasketButton")) { if (rom.vasket) { rom.vasket = false; } else { rom.vasket = true; } } else { if (rom.opptatt) { rom.opptatt = false; } else { rom.opptatt = true; } } db.SaveChanges(); db.Room.Load(); romtypeCombo_SelectionChanged(null, null); } } }