public List <vwManager> GetAllManagersView() { try { using (Nedeljni_IEntities context = new Nedeljni_IEntities()) { List <vwManager> list = new List <vwManager>(); list = (from x in context.vwManagers select x).ToList(); return(list); } } catch (Exception ex) { Debug.WriteLine("Exception" + ex.Message.ToString()); return(null); } }
public bool AddAdministrator(vwAdministrator administrator) { try { using (Nedeljni_IEntities context = new Nedeljni_IEntities()) { tblUser user = new tblUser { Gender = administrator.Gender, JMBG = administrator.JMBG, Residence = administrator.Residence, MarriageStatus = administrator.MarriageStatus, FirstName = administrator.FirstName, Pasword = administrator.Pasword, Surname = administrator.Surname, Username = administrator.Username }; context.tblUsers.Add(user); context.SaveChanges(); administrator.UserID = user.UserID; tblAdministrator newAdministrator = new tblAdministrator { UserID = user.UserID, ExpirationDate = administrator.ExpirationDate, AdministratorType = administrator.AdministratorType }; context.tblAdministrators.Add(newAdministrator); context.SaveChanges(); administrator.AdministratorID = newAdministrator.AdministratorID; return(true); } } catch (Exception ex) { Debug.WriteLine("Exception" + ex.Message.ToString()); return(false); } }