vwOrder IService1.AddOrder(vwOrder order) // AddOrder
        {
            try
            {
                using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
                {
                    if (order.OrderID == 0)
                    {   // ZA ADD
                        tblAlbum albumToEdit = (from r in context.tblAlbums where r.AlbumID == order.AlbumID select r).First();
                        //albumToEdit.GenreID = album.GenreID;
                        //albumToEdit.ArtistID = album.ArtistID;
                        //albumToEdit.Title = album.Title;
                        //albumToEdit.Price = album.Price;
                        albumToEdit.Storage -= order.NumberOfPieces;
                        context.Entry(albumToEdit).State = EntityState.Modified;
                        context.SaveChanges();

                        tblOrder newOrder = new tblOrder();
                        newOrder.EmployeeID     = order.EmployeeID;
                        newOrder.AlbumID        = order.AlbumID;
                        newOrder.CustomerID     = order.CustomerID;
                        newOrder.OrderDate      = order.OrderDate;
                        newOrder.TotalPrice     = order.TotalPrice;
                        newOrder.NumberOfPieces = order.NumberOfPieces;
                        context.tblOrders.Add(newOrder);
                        context.SaveChanges();
                        order.OrderID = newOrder.OrderID;
                        return(order);
                    }
                    else
                    {   // ZA EDIT
                        int      numberOfPieces = (int)(from x in context.vwOrders where x.OrderID == order.OrderID select x.NumberOfPieces).First();
                        tblAlbum albumToEdit    = (from r in context.tblAlbums where r.AlbumID == order.AlbumID select r).First();

                        albumToEdit.Storage = (albumToEdit.Storage + numberOfPieces) - order.NumberOfPieces;
                        context.Entry(albumToEdit).State = EntityState.Modified;
                        context.SaveChanges();

                        tblOrder orderToEdit = (from r in context.tblOrders where r.OrderID == order.OrderID select r).First();
                        orderToEdit.EmployeeID     = order.EmployeeID;
                        orderToEdit.AlbumID        = order.AlbumID;
                        orderToEdit.CustomerID     = order.CustomerID;
                        orderToEdit.OrderDate      = order.OrderDate;
                        orderToEdit.TotalPrice     = order.TotalPrice;
                        orderToEdit.NumberOfPieces = order.NumberOfPieces;
                        //orderToEdit.OrderID = order.OrderID;
                        context.Entry(orderToEdit).State = EntityState.Modified;
                        context.SaveChanges();
                        return(order);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
                return(null);
            }
        }
 // ADD , EDIT I DELETE ZA ARTIST
 vwArtist IService1.AddArtist(vwArtist artist) // AddArtist
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (artist.ArtistID == 0)
             {   // ZA ADD
                 tblArtist newArtist = new tblArtist();
                 newArtist.ArtistName = artist.ArtistName;
                 context.tblArtists.Add(newArtist);
                 context.SaveChanges();
                 artist.ArtistID = newArtist.ArtistID;
                 return(artist);
             }
             else
             {   // ZA EDIT
                 tblArtist artistToEdit = (from r in context.tblArtists where r.ArtistID == artist.ArtistID select r).First();
                 artistToEdit.ArtistName           = artist.ArtistName;
                 context.Entry(artistToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(artist);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
 // ADD , EDIT I DELETE ZA GENRE
 vwGenre IService1.AddGenre(vwGenre genre) // AddGenre
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (genre.GenreID == 0)
             {   // ZA ADD
                 tblGenre newGenre = new tblGenre();
                 newGenre.Name        = genre.Name;
                 newGenre.Description = genre.Description;
                 context.tblGenres.Add(newGenre);
                 context.SaveChanges();
                 genre.GenreID = newGenre.GenreID;
                 return(genre);
             }
             else
             {   // ZA EDIT
                 tblGenre genreToEdit = (from r in context.tblGenres where r.GenreID == genre.GenreID select r).First();
                 genreToEdit.Name                 = genre.Name;
                 genreToEdit.Description          = genre.Description;
                 context.Entry(genreToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(genre);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
 // ADD , EDIT I DELETE ZA EMPLOYEE
 vwEmployee IService1.AddEmployee(vwEmployee employee) // AddEmployee
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (employee.EmployeeID == 0)
             {   // ZA ADD
                 tblEmployee newEmployee = new tblEmployee();
                 newEmployee.BossID           = employee.BossID;
                 newEmployee.EmployeeName     = employee.EmployeeName;
                 newEmployee.EmployeeLastName = employee.EmployeeLastName;
                 newEmployee.BirthDate        = employee.BirthDate;
                 newEmployee.Address          = employee.Address;
                 newEmployee.City             = employee.City;
                 newEmployee.Mobile           = employee.Mobile;
                 newEmployee.JobDescription   = employee.JobDescription;
                 context.tblEmployees.Add(newEmployee);
                 context.SaveChanges();
                 employee.EmployeeID = newEmployee.EmployeeID;
                 return(employee);
             }
             else
             {   // ZA EDIT
                 tblEmployee employeeToEdit = (from r in context.tblEmployees where r.EmployeeID == employee.EmployeeID select r).First();
                 employeeToEdit.BossID           = employee.BossID;
                 employeeToEdit.EmployeeName     = employee.EmployeeName;
                 employeeToEdit.EmployeeLastName = employee.EmployeeLastName;
                 employeeToEdit.BirthDate        = employee.BirthDate;
                 employeeToEdit.Address          = employee.Address;
                 employeeToEdit.City             = employee.City;
                 employeeToEdit.Mobile           = employee.Mobile;
                 employeeToEdit.JobDescription   = employee.JobDescription;
                 //employeeToEdit.EmployeeID = employee.EmployeeID;
                 context.Entry(employeeToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(employee);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
 // ADD , EDIT I DELETE ZA BOSS
 vwBoss IService1.AddBoss(vwBoss boss) // AddBoss
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (boss.BossID == 0)
             {   // ZA ADD
                 tblBoss newBoss = new tblBoss();
                 newBoss.OfficeID       = boss.OfficeID;
                 newBoss.BossName       = boss.BossName;
                 newBoss.BossLastName   = boss.BossLastName;
                 newBoss.BirthDate      = boss.BirthDate;
                 newBoss.Address        = boss.Address;
                 newBoss.City           = boss.City;
                 newBoss.Mobile         = boss.Mobile;
                 newBoss.JobDescritions = boss.JobDescritions;
                 context.tblBosses.Add(newBoss);
                 context.SaveChanges();
                 boss.BossID = newBoss.BossID;
                 return(boss);
             }
             else
             {   // ZA EDIT
                 tblBoss bossToEdit = (from r in context.tblBosses where r.BossID == boss.BossID select r).First();
                 bossToEdit.OfficeID       = boss.OfficeID;
                 bossToEdit.BossName       = boss.BossName;
                 bossToEdit.BossLastName   = boss.BossLastName;
                 bossToEdit.BirthDate      = boss.BirthDate;
                 bossToEdit.Address        = boss.Address;
                 bossToEdit.City           = boss.City;
                 bossToEdit.Mobile         = boss.Mobile;
                 bossToEdit.JobDescritions = boss.JobDescritions;
                 //bossToEdit.BossID = boss.BossID;
                 context.Entry(bossToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(boss);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
 // ADD , EDIT AND DETELE OFFICE
 vwOffice IService1.AddOffice(vwOffice office) // ADD OFFICE
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (office.OfficeID == 0)
             {   //ZA ADD
                 tblOffice newOffice = new tblOffice();
                 newOffice.OfficeName = office.OfficeName;
                 newOffice.City       = office.City;
                 newOffice.Address    = office.Address;
                 newOffice.PostalCode = office.PostalCode;
                 newOffice.Phone      = office.Phone;
                 newOffice.Mobile     = office.Mobile;
                 context.tblOffices.Add(newOffice);
                 context.SaveChanges();
                 office.OfficeID = office.OfficeID;
                 return(office);
             }
             else
             { // ZA EDIT
                 tblOffice officeToEdit = (from f in context.tblOffices where f.OfficeID == office.OfficeID select f).First();
                 officeToEdit.OfficeName = office.OfficeName;
                 officeToEdit.City       = office.City;
                 officeToEdit.Address    = office.Address;
                 officeToEdit.PostalCode = office.PostalCode;
                 officeToEdit.Phone      = office.Phone;
                 officeToEdit.Mobile     = office.Mobile;
                 //officeToEdit.OfficeID = office.OfficeID;
                 context.Entry(officeToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(office);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
 // ADD , EDIT I DELETE ZA CUSTOMER
 vwCustomer IService1.AddCustomer(vwCustomer customer) // AddCustomer
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (customer.CustomerID == 0)
             {   // ZA ADD
                 tblCustomer newCustomer = new tblCustomer();
                 newCustomer.Name     = customer.Name;
                 newCustomer.LastName = customer.LastName;
                 newCustomer.Country  = customer.Country;
                 newCustomer.Address  = customer.Address;
                 newCustomer.City     = customer.City;
                 newCustomer.Mobile   = customer.Mobile;
                 context.tblCustomers.Add(newCustomer);
                 context.SaveChanges();
                 customer.CustomerID = newCustomer.CustomerID;
                 return(customer);
             }
             else
             {   // ZA EDIT
                 tblCustomer customerToEdit = (from r in context.tblCustomers where r.CustomerID == customer.CustomerID select r).First();
                 customerToEdit.Name                 = customer.Name;
                 customerToEdit.LastName             = customer.LastName;
                 customerToEdit.Country              = customer.Country;
                 customerToEdit.Address              = customer.Address;
                 customerToEdit.City                 = customer.City;
                 customerToEdit.Mobile               = customer.Mobile;
                 context.Entry(customerToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(customer);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }
 // ADD , EDIT I DELETE ZA ALBUM
 vwAlbum IService1.AddAlbum(vwAlbum album) // AddAlbum
 {
     try
     {
         using (VinylRecordsShopEntities context = new VinylRecordsShopEntities())
         {
             if (album.AlbumID == 0)
             {   // ZA ADD
                 tblAlbum newAlbum = new tblAlbum();
                 newAlbum.GenreID  = album.GenreID;
                 newAlbum.ArtistID = album.ArtistID;
                 newAlbum.Title    = album.Title;
                 newAlbum.Price    = album.Price;
                 newAlbum.Storage  = album.Storage;
                 context.tblAlbums.Add(newAlbum);
                 context.SaveChanges();
                 album.AlbumID = newAlbum.AlbumID;
                 return(album);
             }
             else
             {   // ZA EDIT
                 tblAlbum albumToEdit = (from r in context.tblAlbums where r.AlbumID == album.AlbumID select r).First();
                 albumToEdit.GenreID              = album.GenreID;
                 albumToEdit.ArtistID             = album.ArtistID;
                 albumToEdit.Title                = album.Title;
                 albumToEdit.Price                = album.Price;
                 albumToEdit.Storage              = album.Storage;
                 context.Entry(albumToEdit).State = EntityState.Modified;
                 context.SaveChanges();
                 return(album);
             }
         }
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString());
         return(null);
     }
 }