/// <summary>
        /// Changes the value of Confirmed on the Hour Registration with the ID sent though the hourReg
        /// </summary>
        /// <param name="hourReg"></param>
        public int ConfirmHourRegistration(HourRegistrationDTO hourReg)
        {
            try
            {
                using (var db = new HourRegistrationEntities())
                {
                    var dbHour = db.HourRegistration.FirstOrDefault(x => x.ID == hourReg.Id);
                    dbHour.Confirmed = true;
                    dbHour.Denied = false;
                    db.SaveChanges();

                    db.HourRegistrationConfirmed.Add(new HourRegistrationConfirmed()
                    {
                        Login_ID = dbHour.LoginProject.Login_ID,
                        Project_ID = dbHour.LoginProject.Project_ID,
                        Head_ID = (long)dbHour.LoginProject.Login.Head_ID,
                        Hours = dbHour.Hours,
                        Comment = dbHour.Comment,
                        Date = dbHour.Date
                    });
                    db.SaveChanges();

                    return 1;
                }
            } catch (Exception e)
            {
                return -1;
            }
        }
        /// <summary>
        /// Changes the Active property of all LoginProjects with the given Login_Id and Project_Id, 
        /// to the given Active
        /// </summary>
        /// <param name="logProj"></param>
        public int ChangeActiveProjectForLogin(LoginProjectDTO logProj)
        {
            try
            {
                using (var db = new HourRegistrationEntities())
                {
                    var dbList = db.LoginProject.Where(x => x.Login_ID == logProj.Login_Id && x.Project_ID == logProj.Project_Id).ToList();
                    if (dbList.Count == 0)
                    {
                        return 2;
                    }
                    foreach (var item in dbList)
                    {
                        item.Active = logProj.Active;
                    }
                    db.SaveChanges();
                    return 1;
                }

            }
            catch (Exception e)
            {
                return -1;
            }
        }
        /// <summary>
        /// Edits the HourRegistration with the given parametres
        /// </summary>
        /// <param name="hourRegistration"></param>
        public int EditHours(HourRegistrationDTO hourRegistration)
        {
            try
            {
                using (var db = new HourRegistrationEntities())
                {
                    var dbHour = db.HourRegistration.Single(x => x.ID == hourRegistration.Id);
                    dbHour.Date = DateTime.Parse(hourRegistration.Date);
                    dbHour.Hours = hourRegistration.Hours;
                    dbHour.Comment = hourRegistration.Comment;
                    db.SaveChanges();
                    return 1;
                }

            } catch(Exception e){
                return -1;
            }
        }
 /// <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>
        /// Returns the HourRegistration with the given stringId
        /// </summary>
        /// <param name="stringId"></param>
        /// <returns>A single HourRegistrationDTO</returns>
        public HourRegistrationDTO GetHourById(string stringId)
        {
            try
            {
                var id = Int32.Parse(stringId);
                using (var db = new HourRegistrationEntities())
                {
                    var dbHour = db.HourRegistration.SingleOrDefault(x => x.ID == id);
                    return new HourRegistrationDTO()
                    {
                    Id = dbHour.ID,
                    LoginProject_Id = dbHour.LoginProject_ID,
                    Hours = dbHour.Hours,
                    Date = dbHour.Date.ToShortDateString(),
                    Comment = dbHour.Comment,
                    LoginProject = new LoginProjectDTO()
                    {
                        Project = new ProjectDTO()
                        {
                        Title = dbHour.LoginProject.Project.Title
                        }
                    }

                    };
                }
            }
            catch (Exception e)
            {
                return new HourRegistrationDTO();
            }
        }
 /// <summary>
 /// Returns the Login with the given stringId
 /// </summary>
 /// <param name="stringId"></param>
 /// <returns>A single LoginDTO</returns>
 public LoginDTO GetLoginById(string stringId)
 {
     try
     {
         var id = Int32.Parse(stringId);
         using (var db = new HourRegistrationEntities())
         {
             var dbLogin = db.Login.SingleOrDefault(x => x.ID == id);
             return new LoginDTO()
             {
                 Id = dbLogin.ID,
                 Name = dbLogin.Name,
                 Username = dbLogin.Username,
                 Password = dbLogin.Password,
                 Head_Id = dbLogin.Head_ID,
                 Role = new RoleDTO()
                 {
                     Id = dbLogin.Role.ID,
                     Role1 = dbLogin.Role.Role1
                 }
             };
         }
     }
     catch (Exception e)
     {
         return new LoginDTO();
     }
 }
 //LOGIN OPERATIONS
 //comment
 /// <summary>
 /// Returns all Logins
 /// </summary>
 /// <returns>A list of LoginDTO</returns>
 public List<LoginDTO> GetLogins()
 {
     var dtoList = new List<LoginDTO>();
     try
     {
         using (var db = new HourRegistrationEntities())
         {
             var list = db.Login.Where(x => x.InActive == false).ToList();
             //If the list from the DB is empty
             if (list.Count == 0)
             {
                 return dtoList;
             }
             foreach (var login in list)
             {
                 dtoList.Add(new LoginDTO()
                 {
                     Id = login.ID,
                     Name = login.Name,
                     Username = login.Username,
                     Password = login.Password,
                     Role = new RoleDTO()
                     {
                     Id = login.Role.ID,
                     Role1 = login.Role.Role1
                     }
                 });
             }
         }
         return dtoList;
     }
     catch (Exception e)
     {
         return dtoList;
     }
 }
 //ROLES OPEARATIONS
 /// <summary>
 /// Returns a list of all Roles, only taking the number of entries defined by take,
 /// skipping entries defined by skip, and searching for entries defined by searchValue (if any)
 /// </summary>
 /// <returns>A list of RoleDTO</returns>
 public List<RoleDTO> GetAllRoles(string take, string skip, string searchValue)
 {
     var dbRoles = new List<Role>();
     var returnList = new List<RoleDTO>();
     try
     {
         int takeInt = Int32.Parse(take);
         int skipInt = Int32.Parse(skip);
         using (var db = new HourRegistrationEntities())
         {
             if (searchValue != "null")
             {
             dbRoles =
                 db.Role.Where(x => x.Role1.Contains(searchValue))
                 .OrderBy(x => x.Role1)
                 .Take(takeInt)
                 .Skip(skipInt)
                 .ToList();
             }
             else
             {
                 dbRoles = db.Role.OrderBy(x => x.Role1).Take(takeInt).Skip(skipInt).ToList();
             }
             //If the list from the DB is empty
             if (dbRoles.Count == 0)
             {
                 return returnList;
             }
             foreach (var role in dbRoles)
             {
                 returnList.Add(new RoleDTO()
                 {
                     Id = role.ID,
                     Role1 = role.Role1
                 });
             }
             return returnList;
         }
     }
     catch(Exception e)
     {
         return returnList;
     }
 }
        /// <summary>
        /// Creates a new Project with the given parametres
        /// </summary>
        /// <param name="project"></param>
        public int CreateProject(ProjectDTO project)
        {
            try
            {
                using (var db = new HourRegistrationEntities())
                {
                    var cust = db.Cust.SingleOrDefault(x => x.Name == project.Customer.Name);
                    if (cust != null)
                    {
                        db.Project.Add(new Project()
                        {
                            Title = project.Title,
                            Cust_ID = cust.ID
                        });

                        db.SaveChanges();
                    }
                    else
                    {
                        var newCust = new Cust()
                        {
                            Name = project.Customer.Name
                        };

                        db.Cust.Add(newCust);
                        db.SaveChanges();

                        var custId = newCust.ID;

                        db.Project.Add(new Project()
                        {
                            Title = project.Title,
                            Cust_ID = custId
                        });

                        db.SaveChanges();
                    }
                    return 1;
                }
            }
            catch (Exception e)
            {
              return -1;
            }
        }
 /// <summary>
 /// Returns all HourRegistration that needs action from the Head
 /// </summary>
 /// <param name="stringId"></param>
 /// <returns>A list of HourRegistrationDTO</returns>
 public List<HourRegistrationDTO> GetAllHourRegsForHead(string stringId)
 {
     var returnList = new List<HourRegistrationDTO>();
     try
     {
         var id = Int32.Parse(stringId);
         using (var db = new HourRegistrationEntities())
         {
             var dbHours =
             db.HourRegistration.Where(
                 x => x.LoginProject.Login.Head_ID == id && x.Confirmed == false && x.Denied == false).ToList();
             //If the list from the DB is empty
             if (dbHours.Count == 0)
             {
                 return returnList;
             }
             foreach (var item in dbHours)
             {
                 var denyComment = "No comment";
                 if(item.CommentDeny != "null")
                 {
                     denyComment = item.CommentDeny;
                 }
                 returnList.Add(new HourRegistrationDTO()
                 {
                     Id = item.ID,
                     LoginProject_Id = item.LoginProject_ID,
                     Hours = item.Hours,
                     Date = item.Date.ToShortDateString(),
                     Comment = item.Comment,
                     CommentDeny = denyComment,
                     LoginProject = new LoginProjectDTO()
                     {
                         Login = new LoginDTO()
                         {
                             Name = item.LoginProject.Login.Name
                         },
                         Project = new ProjectDTO()
                         {
                             Title = item.LoginProject.Project.Title
                         }
                     }
                 });
             }
             return returnList;
         }
     }
     catch (Exception e)
     {
         return returnList;
     }
 }
 /// <summary>
 /// Return the Role with the given stringId
 /// </summary>
 /// <param name="stringId"></param>
 /// <returns>A single RoleDTO</returns>
 public RoleDTO GetRoleById(string stringId)
 {
     try
     {
         int id = Int32.Parse(stringId);
         using (var db = new HourRegistrationEntities())
         {
             var dbRole = db.Role.FirstOrDefault(x => x.ID == id);
             return new RoleDTO()
             {
                 Id = dbRole.ID,
                 Role1 = dbRole.Role1
             };
         }
     }
     catch (Exception e)
     {
         return new RoleDTO();
     }
 }
 /// <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;
     }
 }
 //HOUR REGISTRATION OPERATIONS
 /// <summary>
 /// Returns all projects for a the Login with the given stringId
 /// </summary>
 /// <param name="stringId"></param>
 /// <returns>A list of ProjectDTO</returns>
 public List<ProjectDTO> GetProjectsForLogin(string stringId)
 {
     var projList = new List<ProjectDTO>();
     try
     {
         var id = Int32.Parse(stringId);
         using (var db = new HourRegistrationEntities())
         {
             var list =
             db.HourRegistration.Where(x => x.LoginProject.Login_ID == id && x.LoginProject.Active == true)
                 .GroupBy(x => x.LoginProject.Project_ID)
                 .Select(x => x.FirstOrDefault())
                 .ToList();
             //If the list from the DB is empty
             if (list.Count == 0)
             {
                 return projList;
             }
             foreach (var hour in list)
             {
                 projList.Add(new ProjectDTO()
                 {
                     Id = hour.LoginProject.Project_ID,
                     Title = hour.LoginProject.Project.Title
                 });
             }
             return projList;
         }
     }
     catch (Exception e)
     {
         return projList;
     }
 }
        /// <summary>
        /// Creates a new HourRegistration with the given parametres
        /// </summary>
        /// <param name="hourRegistration"></param>
        public int CreateHours(HourRegistrationDTO hourRegistration)
        {
            try
            {
                var actualDate = new String(hourRegistration.Date.ToCharArray().Where(c => c <= 255).ToArray());

                if (hourRegistration.Comment == "")
                {
                    hourRegistration.Comment = "No comment";
                }

                using (var db = new HourRegistrationEntities())
                {
                    var newLogin = new LoginProject()
                    {
                        Active = true,
                        Login_ID = hourRegistration.LoginProject.Login_Id,
                        Project_ID = hourRegistration.LoginProject.Project_Id
                    };

                    db.LoginProject.Add(newLogin);
                    db.SaveChanges();

                    long id = newLogin.ID;

                    db.HourRegistration.Add(new HourRegistration()
                    {
                        Date = DateTime.Parse(actualDate),
                        Hours = hourRegistration.Hours,
                        Comment = hourRegistration.Comment,
                        LoginProject_ID = id,
                        Confirmed = false,
                        Denied = false
                    });

                    db.SaveChanges();
                    return 1;
                }
            }
            catch (DbEntityValidationException e)
            {
                return -2;
            }
            catch (Exception e)
            {
              return -1;
            }
        }
 /// <summary>
 /// Return the Project with the given stringId
 /// </summary>
 /// <param name="stringId"></param>
 /// <returns>A single ProjectDTO</returns>
 public ProjectDTO GetProjectByID(string stringId)
 {
     try
     {
         var id = Int32.Parse(stringId);
         using (var db = new HourRegistrationEntities())
         {
             var dbProject = db.Project.SingleOrDefault(x => x.ID == id);
             return new ProjectDTO()
             {
             Id = dbProject.ID,
             Cust_id = dbProject.Cust_ID,
             Title = dbProject.Title
             };
         }
     }
     catch (Exception e)
     {
         return new ProjectDTO();
     }
 }
        /// <summary>
        /// Return a list of all denied Hour Registration for the Login with the given stringId
        /// </summary>
        /// <param name="stringId"></param>
        /// <returns>A list of HourRegistrationDTO</returns>
        public List<HourRegistrationDTO> GetAllDeniedHoursForLogin(string stringId)
        {
            var returnList = new List<HourRegistrationDTO>();
            try
            {
                var id = Int32.Parse(stringId);
                using (var db = new HourRegistrationEntities())
                {
                    var dbHours = db.HourRegistration.Where(x => x.LoginProject.Login.ID == id && x.Denied == true).ToList();
                    //If the list from the DB is empty
                    if (dbHours.Count == 0)
                    {
                        return returnList;
                    }
                    foreach (var item in dbHours)
                    {
                        returnList.Add(new HourRegistrationDTO()
                        {
                            Id = item.ID,
                            Hours = item.Hours,
                            Date = item.Date.ToShortDateString(),
                            Comment = item.Comment,
                            CommentDeny = item.CommentDeny,
                            LoginProject = new LoginProjectDTO()
                            {
                                Project = new ProjectDTO()
                                {
                                    Title = item.LoginProject.Project.Title
                                }
                            }
                        });
                    }

                    return returnList;
                }
            }
            catch (Exception e)
            {
                return returnList;
            }
        }
        /// <summary>
        /// Return all HourRegistrations for the Login with the given stringID and from the last months back with the given stringMonthCount
        /// </summary>
        /// <param name="stringId"></param>
        /// <param name="stringMonthCount"></param>
        /// <returns>A list of HourRegistrationDTO</returns>
        public List<HourRegistrationDTO> GetAllHoursForLoginXMonth(string stringId, string stringMonthCount)
        {
            var hourRegs = new List<HourRegistrationDTO>();
            try
            {
                int id = Int32.Parse(stringId);
                int monthCount = Int32.Parse(stringMonthCount);

                using (var db = new HourRegistrationEntities())
                {
                    var monthDate = DateTime.Now.AddMonths(-monthCount);
                    var dbHourRegs = db.HourRegistration
                    .Where(x => x.LoginProject.Login_ID == id && x.Date > monthDate)
                    .ToList();

                    //If the list from the DB is empty
                    if (dbHourRegs.Count == 0)
                    {
                        return hourRegs;
                    }

                    foreach (var item in dbHourRegs)
                    {
                        hourRegs.Add(new HourRegistrationDTO()
                        {
                            Id = item.ID,
                            LoginProject_Id = item.LoginProject_ID,
                            Hours = item.Hours,
                            Date = item.Date.ToShortDateString(),
                            Comment = item.Comment,
                            LoginProject = new LoginProjectDTO()
                            {
                                Project = new ProjectDTO()
                                {
                                    Title = item.LoginProject.Project.Title
                                }
                            }
                        });
                    }
                    return hourRegs;
                }
            }
            catch (Exception e)
            {
                return hourRegs;
            }
        }
 /// <summary>
 /// Returns all Logins with Role_ID 1, only taking the number of entries defined by take,
 /// skipping entries defined by skip, and searching for entries defined by searchValue (if any)
 /// </summary>
 /// <returns>A list of LoginDTO</returns>
 public List<LoginDTO> GetAllHeads(string take, string skip, string searchValue)
 {
     var dbLogins = new List<Login>();
     var returnList = new List<LoginDTO>();
     try
     {
         var takeInt = Int32.Parse(take);
         var skipInt = Int32.Parse(skip);
         using (var db = new HourRegistrationEntities())
         {
             if (searchValue != "null")
             {
                 dbLogins =
                     db.Login.Where(x => x.Role_ID == 1 && x.Name.Contains(searchValue) && x.InActive == false)
                     .OrderBy(x => x.Name)
                     .Take(takeInt)
                     .Skip(skipInt)
                     .ToList();
             }
             else
             {
                 dbLogins =
                     db.Login.Where(x => x.Role_ID == 1 && x.InActive == false)
                     .OrderBy(x => x.Name)
                     .Take(takeInt)
                     .Skip(skipInt)
                     .ToList();
             }
             //If the list from the DB is empty
             if (dbLogins.Count == 0)
             {
                 return returnList;
             }
             foreach (var login in dbLogins)
             {
                 returnList.Add(new LoginDTO()
                 {
                     Id = login.ID,
                     Name = login.Name,
                     Username = login.Username,
                     Role = new RoleDTO()
                     {
                     Role1 = login.Role.Role1
                     }
                 });
             }
             return returnList;
         }
     }
     catch (Exception e)
     {
         return returnList;
     }
 }
        //PROJECT OPERTIONS
        /// <summary>
        /// Returns all Projects
        /// </summary>
        /// <returns>A list of ProjectDTO</returns>
        public List<ProjectDTO> GetAllProjects(string take, string skip, string searchValue)
        {
            var projectList = new List<ProjectDTO>();
            try
            {
                var takeInt = Int32.Parse(take);
                var skipInt = Int32.Parse(skip);
                using (var db = new HourRegistrationEntities())
                {
                    var dbList = new List<Project>();
                    if (searchValue != "null")
                    {
                        dbList =
                            db.Project.OrderBy(x => x.Title)
                            .Where(x => x.Title.Contains(searchValue))
                            .Skip(skipInt)
                            .Take(takeInt)
                            .ToList();
                    }
                    else
                    {
                        dbList = db.Project.OrderBy(x => x.Title).Skip(skipInt).Take(takeInt).ToList();
                    }

                    //If the list from the DB is empty
                    if (dbList.Count == 0)
                    {
                        return projectList;
                    }

                    foreach (var project in dbList)
                    {
                        var proj = new ProjectDTO()
                        {
                            Id = project.ID,
                            Title = project.Title,
                            Cust_id = project.Cust_ID,
                            Customer = new CustomerDTO()
                            {
                            Id = project.Cust.ID,
                            Name = project.Cust.Name,
                            }
                        };
                        projectList.Add(proj);
                    }
                    return projectList;
                }
            }
            catch (Exception e)
            {
                return projectList;
            }
        }
        /// <summary>
        /// Deletes the HourRegistration with the given stringId
        /// </summary>
        /// <param name="stringId"></param>
        public int DeleteHours(string stringId)
        {
            try
            {
                var id = Int32.Parse(stringId);
                using (var db = new HourRegistrationEntities())
                {
                    var hours = db.HourRegistration.SingleOrDefault(x => x.ID == id);
                    db.SaveChanges();
                    return 1;
                }

            } catch(Exception e){
                return -1;
            }
        }
 /// <summary>
 /// Returns the Login with the given username
 /// </summary>
 /// <param name="username"></param>
 /// <returns>A single LoginDTO</returns>
 public LoginDTO GetLoginByUsername(string username)
 {
     try
     {
         using (var db = new HourRegistrationEntities())
         {
             var dbLogin = db.Login.Include(x => x.Role).SingleOrDefault(x => x.Username == username);
             if (dbLogin == null)
             {
                 return new LoginDTO();
             }
             if (dbLogin.InActive)
             {
                 dbLogin.InActive = false;
                 db.SaveChanges();
                 return new LoginDTO()
                 {
                     Id = dbLogin.ID,
                     Name = dbLogin.Name,
                     Username = dbLogin.Username,
                     Password = dbLogin.Password,
                     InActive = true,
                     Head_Id = dbLogin.Head_ID,
                     Role = new RoleDTO()
                     {
                         Id = dbLogin.Role.ID,
                         Role1 = dbLogin.Role.Role1
                     }
                 };
             }
             return new LoginDTO()
             {
                 Id = dbLogin.ID,
                 Name = dbLogin.Name,
                 Username = dbLogin.Username,
                 Password = dbLogin.Password,
                 Head_Id = dbLogin.Head_ID,
                 Role = new RoleDTO()
                 {
                     Id = dbLogin.Role.ID,
                     Role1 = dbLogin.Role.Role1
                 }
             };
         }
     }
     catch (Exception e)
     {
         return new LoginDTO();
     }
 }
        /// <summary>
        /// Return a list with all Logins with the given Head_ID, stringId
        /// </summary>
        /// <param name="stringId"></param>
        /// <returns>A list of LoginDTO</returns>
        public List<LoginDTO> GetAllLoginsForChief(string stringId)
        {
            var returnList = new List<LoginDTO>();
            try
            {
                var id = Int32.Parse(stringId);

                using (var db = new HourRegistrationEntities())
                {
                    var dbList = db.Login.Where(x => x.Head_ID == id && x.InActive == false).ToList();
                    //If the list from the DB is empty
                    if (dbList.Count == 0)
                    {
                        return returnList;
                    }
                    foreach (var item in dbList)
                    {
                        returnList.Add(new LoginDTO()
                        {
                            Name = item.Name
                        });
                    }
                    return returnList;
                }
            }
            catch (Exception e)
            {
                return returnList;
            }
        }
        /// <summary>
        /// Deletes the Login with the given stringId
        /// </summary>
        /// <param name="stringId"></param>
        public int DeleteLogin(string stringId)
        {
            try
            {
                var id = Int32.Parse(stringId);
                using (var db = new HourRegistrationEntities())
                {
                    var dbLogin = db.Login.SingleOrDefault(x => x.ID == id);
                    dbLogin.InActive = true;
                    db.SaveChanges();
                    return 1;
                }

            } catch(Exception e){
                return -1;
            }
        }
        /// <summary>
        /// Returns all Projects with the given Login.ID, stringId
        /// </summary>
        /// <param name="stringId"></param>
        /// <returns>A list of ProjectDTO</returns>
        public List<ProjectDTO> GetAllProjectsWithLoginId(string stringId)
        {
            var projectList = new List<ProjectDTO>();
            try
            {
                using (var db = new HourRegistrationEntities())
                {
                    var list = db.Project.ToList();
                    int loginId = Int32.Parse(stringId);
                    //If the list from the DB is empty
                    if (list.Count == 0)
                    {
                        return projectList;
                    }
                    foreach (var project in list)
                    {
                        var active = false;
                        try
                        {
                            active = (bool)db.LoginProject
                                .FirstOrDefault(x => x.Login_ID == loginId && x.Project_ID == project.ID)
                                .Active;
                        }
                        catch (Exception e)
                        {

                        }

                        var proj = new ProjectDTO()
                        {
                            Id = project.ID,
                            Title = project.Title,
                            Cust_id = project.Cust_ID,
                            Customer = new CustomerDTO()
                            {
                                Id = project.Cust.ID,
                                Name = project.Cust.Name,
                            },
                            LoginActive = active
                        };
                        projectList.Add(proj);
                    }
                }
                return projectList;
            }
            catch(Exception e)
            {
              return projectList;
            }
        }
        /// <summary>
        /// Deletes the Project with the given stringId
        /// </summary>
        /// <param name="stringId"></param>
        public int DeleteProject(string stringId)
        {
            try
            {
                var id = Int32.Parse(stringId);
                using (var db = new HourRegistrationEntities())
                {
                    var dbProject = db.Project.SingleOrDefault(x => x.ID == id);
                    db.Project.Remove(dbProject);
                    db.SaveChanges();
                    return 1;
                }

            } catch (Exception e){
                return -1;
            }
        }
 /// <summary>
 /// Correct a denied HourRegistration with the given parametres 
 /// </summary>
 /// <param name="hourReg"></param>
 public int CorrectDeneidHourRegistration(HourRegistrationDTO hourReg)
 {
     try
     {
         var actualDate = new String(hourReg.Date.ToCharArray().Where(c => c <= 255).ToArray());
         if (hourReg.Comment == "")
         {
             hourReg.Comment = "No comment";
         };
         using (var db = new HourRegistrationEntities())
         {
             var dbHour = db.HourRegistration.FirstOrDefault(x => x.ID == hourReg.Id);
             dbHour.Hours = hourReg.Hours;
             dbHour.Date = DateTime.Parse(actualDate);
             dbHour.Comment = hourReg.Comment;
             dbHour.Denied = false;
             db.SaveChanges();
             return 1;
         }
     }
     catch (DbEntityValidationException e)
     {
         return -2;
     }
     catch (Exception e)
     {
         return -1;
     }
 }
        /// <summary>
        /// Changes the value of Confirmed on the Hour Registration with the ID sent though the hourReg and adds a comment containing why it's been denied
        /// </summary>
        /// <param name="hourReg"></param>
        public int DenyHourRegistration(HourRegistrationDTO hourReg)
        {
            try
            {
                using (var db = new HourRegistrationEntities())
                {
                    var dbHour = db.HourRegistration.FirstOrDefault(x => x.ID == hourReg.Id);
                    dbHour.CommentDeny = hourReg.CommentDeny;
                    dbHour.Denied = true;
                    db.SaveChanges();

                    return 1;
                }
            }
            catch (Exception e)
            {
                return -1;
            }
        }
        /// <summary>
        /// Gets all the HourRegistration with the given stringId
        /// </summary>
        /// <param name="stringId"></param>
        /// <returns>A list of HourRegistrationDTO</returns>
        public List<HourRegistrationDTO> GetHoursForLoginProject(string loginStringId, string proStringId)
        {
            var hourList = new List<HourRegistrationDTO>();
            try
            {
                var logId = Int32.Parse(loginStringId);
                var projId = Int32.Parse(proStringId);
                using (var db = new HourRegistrationEntities())
                {
                    var dbHours = db.HourRegistration
                    .Where(x => x.LoginProject.Login_ID == logId && x.LoginProject.Project_ID == projId)
                    .ToList()
                    .Where(x => GetIso8601WeekOfYear(x.Date) == GetIso8601WeekOfYear(DateTime.Now))
                    .ToList();

                    //If the list from the DB is empty
                    if (dbHours.Count == 0)
                    {
                        return hourList;
                    }
                    foreach (var hour in dbHours)
                    {
                        hourList.Add(new HourRegistrationDTO()
                        {
                            Id = hour.ID,
                            LoginProject_Id = hour.LoginProject_ID,
                            Hours = hour.Hours,
                            Date = hour.Date.ToShortDateString(),
                            Comment = hour.Comment,
                            LoginProject = new LoginProjectDTO()
                            {
                                Project = new ProjectDTO()
                                {
                                    Id = hour.LoginProject.Project_ID,
                                    Title = hour.LoginProject.Project.Title
                                }
                            }

                        });
                    }
                    return hourList;
                }
            }
            catch (Exception e)
            {
                return hourList;
            }
        }
 /// <summary>
 /// Returns all the HourRegistration with the given Cust_ID (stringId)
 /// </summary>
 /// <param name="stringId"></param>
 /// <returns>A list of HourRegistrationDTO</returns>
 public List<HourRegistrationDTO> GetHoursForProject(string stringId)
 {
     var hourList = new List<HourRegistrationDTO>();
     try
     {
         var id = Int32.Parse(stringId);
         using (var db = new HourRegistrationEntities())
         {
             var dbHours = db.HourRegistration.Where(x => x.LoginProject.Project_ID == id).ToList();
             //If the list from the DB is empty
             if (dbHours.Count == 0)
             {
                 return hourList;
             }
             foreach (var hour in dbHours)
             {
                 hourList.Add(new HourRegistrationDTO()
                 {
                     Id = hour.ID,
                     LoginProject_Id = hour.LoginProject_ID,
                     Hours = hour.Hours,
                     Date = hour.Date.ToShortDateString(),
                     Comment = hour.Comment,
                     LoginProject = new LoginProjectDTO()
                     {
                         Project = new ProjectDTO()
                         {
                             Id = hour.LoginProject.Project_ID,
                             Title = hour.LoginProject.Project.Title
                         }
                     }
                 });
             }
             return hourList;
         }
     }
     catch (Exception e)
     {
         return hourList;
     }
 }