Esempio n. 1
0
        //Deleting owner profile
        public static void DeleteProfile(int selectedOwnerId)
        {
            using (var context = new FakturyContext())
            {
                var query = context.Owners
                    .Where(n => n.Id == selectedOwnerId)
                    .FirstOrDefault();

                context.Owners.Remove(query);
                context.SaveChanges();
            }
        }
Esempio n. 2
0
        //Deleting client profile
        public static void DeleteClient(int selectedClientId)
        {
            using (var context = new FakturyContext())
            {
                var query = context.Clients
                    .Where(n => n.Id == selectedClientId)
                    .FirstOrDefault();

                context.Clients.Remove(query);
                context.SaveChanges();
            }
        }
Esempio n. 3
0
 //Adding client to DB
 public static void AddClient(Client client)
 {
     using (var context = new FakturyContext())
     {
         context.Clients.Add(client);
         context.SaveChanges();
     }
 }
Esempio n. 4
0
        //Saving invoice
        public static void SaveInvoice(Invoice invoiceToSave)
        {
            using (var context = new FakturyContext())
            {
                var client = context.Clients
                    .Where(n => n.NIP == invoiceToSave.Client.NIP)
                    .First();

                var owner = context.Owners
                    .Where(n => n.NIP == invoiceToSave.Owner.NIP)
                    .First();
                Invoice invoice = new Invoice(invoiceToSave.Date, invoiceToSave.NumberOfInvoice, client, owner, invoiceToSave.products);

                context.Invoices.Add(invoice);
                context.SaveChanges();
            }
        }
Esempio n. 5
0
 //Editing owner data
 public static void EditOwnerData(int id, string name, string address, string city, string postcode, string nip)
 {
     using (var context = new FakturyContext())
     {
         var owner = context.Owners
             .Where(n => n.Id == id)
             .FirstOrDefault();
         owner.Name = name;
         owner.Address = address;
         owner.City = city;
         owner.PostCode = postcode;
         owner.NIP = nip;
         context.SaveChanges();
     }
 }
Esempio n. 6
0
 //Editing client data
 public static void EditClientData(int id, string name, string address, string city, string postcode, string nip)
 {
     using (var context = new FakturyContext())
     {
         var client = context.Clients
             .Where(n => n.Id == id)
             .FirstOrDefault();
         client.Name = name;
         client.Address = address;
         client.City = city;
         client.PostCode = postcode;
         client.NIP = nip;
         context.SaveChanges();
     }
 }
Esempio n. 7
0
 //Adding owner to DB
 public static void AddOwner(Owner owner)
 {
     using (var context = new FakturyContext())
     {
         context.Owners.Add(owner);
         context.SaveChanges();
     }
 }