void IService1.DeleteBoss(int bossID) // DeleteBoss { try { using (VinylRecordsShopEntities context = new VinylRecordsShopEntities()) { tblBoss bossToDelete = (from r in context.tblBosses where r.BossID == bossID select r).First(); context.tblBosses.Remove(bossToDelete); context.SaveChanges(); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception" + ex.Message.ToString()); } }
// 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); } }