public void delete(Guid bookedServiceID) { try { using (ApplicationDbContext db = new ApplicationDbContext()) { using (var transaction = db.Database.BeginTransaction()) { try { BookedServicesRepository repo = new BookedServicesRepository(db); BookedService bookedService = repo.getByID(bookedServiceID.ToString()); if (bookedService != null && !bookedService.IsPaid && !bookedService.IsFinished) { repo.delete(bookedService); db.SaveChanges(); transaction.Commit(); } else { transaction.Rollback(); } } catch (Exception ex) { transaction.Rollback(); } } } } catch (Exception ex) { } }
public BookedService createForFamilyMember(Guid serviceID, Guid familyMemberID, Guid deadPersonID) { try { BookedService bookedService = null; using (ApplicationDbContext db = new ApplicationDbContext()) { Service service = new ServicesRepository(db).getByID(serviceID.ToString()); DeadPerson deadPerson = new DeadPersonRepository(db).getByID(deadPersonID.ToString()); bookedService = new BookedService { BookedServiceID = Guid.NewGuid(), Name = service.Name, Description = service.Description, FamilyMemberID = familyMemberID, PriceGross = service.PriceGross, BurialPlaceID = deadPerson.BurialPlaceID, IsFinished = false, IsPaid = false, CreationDateTime = DateTime.Now }; new BookedServicesRepository(db).create(bookedService); db.SaveChanges(); } return(bookedService); } catch (Exception ex) { } return(null); }
public void update(BookedService service) { try { using (ApplicationDbContext db = new ApplicationDbContext()) { new BookedServicesRepository(db).update(service); db.SaveChanges(); } } catch (Exception ex) { } }
private void btnSub_Click(object sender, RoutedEventArgs e) { Service service = ((FrameworkElement)sender).DataContext as Service; txtbSelected.Text = string.Empty; serviceQuery.Remove(service.Name); txtbSelected.Text = string.Empty; string[] sauce = serviceQuery.ToArray(); var searchTerm = service.Name; var ssQuery = from word in sauce where word.ToLowerInvariant() == searchTerm.ToLowerInvariant() select word; var ssCount = ssQuery.Count(); if (ssCount == 0) { foreach (var servicetype in serviceQty.Where(w => w.serviceName == service.Name)) { removethis = servicetype; Total -= service.Price; } serviceQty.Remove(removethis); foreach (var ss in serviceQty) { txtbSelected.Text = txtbSelected.Text + ss.serviceName + "x" + ss.serviceCount + "\n"; } lblTotal.Content = Total.ToString(); } if (ssCount > 0) { foreach (var servicetype in serviceQty.Where(w => w.serviceName == service.Name)) { servicetype.serviceCount = ssCount; } Total -= service.Price; foreach (var ss in serviceQty) { txtbSelected.Text = txtbSelected.Text + ss.serviceName + "x" + ss.serviceCount + "\n"; } lblTotal.Content = Total.ToString(); } }
public void pay(Guid bookedServiceID) { try { using (ApplicationDbContext db = new ApplicationDbContext()) { BookedService bookedService = new BookedService() { BookedServiceID = bookedServiceID, IsPaid = true }; new BookedServicesRepository(db).pay(bookedService); db.SaveChanges(); } } catch (Exception ex) { } }
public static Operation Add(BookedService bServices) { try { db.BookedServices.Add(bServices); db.SaveChanges(); return(new Operation() { Code = "200", Message = "Ok", ReferenceId = bServices.bsID }); } catch (Exception e) { return(new Operation() { Code = "500", Message = e.Message }); } }
public BookedServiceViewModel(BookedService bookedService, DeadPerson deadPerson) { this.BookedService = bookedService; this.DeadPerson = deadPerson; }