private void DeliverSelectedGarment() { if (SelectedGarment == null) { MessageBox.Show("Please, click on a garment on the list first"); } else { if (SelectedGarment.Paid) { MessageBox.Show("The selected garment has already been delivered"); } else { LaundryDb db; using (db = new LaundryDb()) { db.Garments.Find(SelectedGarment.Id).Paid = true; db.SaveChanges(); } _garments.Remove(SelectedGarment); OnPropertyChanged("Garments"); } } }
private void PerformPayment() { if (SelectedTicket != null) { if (Payment < 0) { MessageBox.Show("Please, input a non-negative value"); } else { LaundryDb db; double payment = Payment; double remanent = SelectedTicket.TotalAmount - SelectedTicket.PaidAmount; if (payment >= remanent) { payment = remanent; } using (db = new LaundryDb()) { db.Tickets.Find(SelectedTicket.Id).PaidAmount += payment; db.SaveChanges(); } ShowTicket(); } } else { MessageBox.Show("Please, pick a Ticket first"); } }
public void SaveTicket() { CalculateTotalAmount(); if (IsValidate()) { _ticket.Garments = _garments; using (_db = new LaundryDb()) { for (int i = 0; i < _garments.Count(); i++) { _db.Garments.Add(_garments[i]); } _db.Tickets.Add(_ticket); _db.SaveChanges(); } Initialize(); } }
private void DeliverAllGarments() { if (SelectedTicket == null) { MessageBox.Show("Please, pick a ticket first"); } else { LaundryDb db; using (db = new LaundryDb()) { var garmentsToFlagAsPaid = db.Garments.Where(g => g.TicketId == SelectedTicket.Id); foreach (var g in garmentsToFlagAsPaid) { g.Paid = true; } db.SaveChanges(); } _garments.Clear(); OnPropertyChanged("Garments"); } }