/// <summary>
 /// Edits the Login with the given ID and the new parametres
 /// </summary>
 /// <param name="login"></param>
 public int EditLogin(LoginDTO login)
 {
     try
     {
         using (var db = new HourRegistrationEntities())
         {
             var dbLogin = db.Login.Single(x => x.ID == login.Id);
             dbLogin.Name = login.Name;
             dbLogin.Username = login.Username;
             if (login.Head_Id == 0)
             {
                 dbLogin.Head_ID = null;
             }
             else
             {
                 dbLogin.Head_ID = login.Head_Id;
             }
             dbLogin.Role_ID = login.Role_Id;
             db.SaveChanges();
             return 1;
         }
     } catch(Exception e){
         return -1;
     }
 }
 /// <summary>
 /// Creates a new Login with the given parametres in login
 /// </summary>
 /// <param name="login"></param>
 public int CreateLogin(LoginDTO login)
 {
     try
     {
         using (var db = new HourRegistrationEntities())
         {
             try
             {
                 db.Login.Add(new Login()
                 {
                     Name = login.Name,
                     Username = login.Username,
                     Password = login.Password,
                     Role_ID = login.Role_Id,
                     Head_ID = login.Head_Id,
                     InActive = false
                 });
                 db.SaveChanges();
                 return 1;
             }
             catch (DbUpdateException e)
             {
                 return -2;
             }
         }
     }
     catch (Exception e)
     {
         return -1;
     }
 }