public bool AddNewProject(Project project)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _projectRepository = new ProjectRepository(unitOfWork);
             int addNewProject = _projectRepository.AddNewProject(project);
             if (addNewProject == 1)
             {
                 unitOfWork.Commit();
                 return(true);
             }
             else
             {
                 unitOfWork.Rollback();
                 return(false);
             }
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
Exemple #2
0
 public bool AddNewAsset(Asset asset)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _assetRepository = new AssetRepository(unitOfWork);
             asset.Asset_Id   = Guid.NewGuid().ToString();
             if (_assetRepository.AddNewAsset(asset) == 1)
             {
                 unitOfWork.Commit();
                 return(true);
             }
             else
             {
                 unitOfWork.Rollback();
                 return(false);
             }
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
 public bool RemoveEmpFromProject(string Project_Employee_id)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _projectEmployeeRepository = new ProjectEmployeeRepository(unitOfWork);
             int response = _projectEmployeeRepository.RemoveEmpFromProject(Project_Employee_id);
             if (response == 1)
             {
                 unitOfWork.Commit();
                 return(true);
             }
             else
             {
                 unitOfWork.Rollback();
                 return(false);
             }
         }
         catch
         {
             throw;
         }
     }
 }
 public bool AddNewProjectTask(ProjectTask projectTask)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _projectTaskRepository      = new ProjectTaskRepository(unitOfWork);
             projectTask.Added_Datetime  = DateTime.Now;
             projectTask.Project_Task_Id = Guid.NewGuid().ToString();
             if (_projectTaskRepository.AddNewProjectTask(projectTask) == 1)
             {
                 unitOfWork.Commit();
                 return(true);
             }
             else
             {
                 unitOfWork.Rollback();
                 return(true);
             }
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
Exemple #5
0
 public List <Employee> SearchEMPByData(string data)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         _employeeRepo = new EmployeeRepo(unitOfWork);
         return(_employeeRepo.SearchEMPByData(data));
     }
 }
        public bool AddNewEmpToProject(string EMPId, string projectId)
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();
                try
                {
                    _projectEmployeeRepository = new ProjectEmployeeRepository(unitOfWork);
                    int existing = _projectEmployeeRepository.CheckEmployeeIsExisting(EMPId, projectId);

                    Console.WriteLine("existing {0}", existing);
                    if (existing == 0)
                    {
                        //can add
                        ProjectEmployee projectEmployee = new ProjectEmployee();
                        projectEmployee.Project_Employee_id = Guid.NewGuid().ToString();
                        projectEmployee.Added_Datetime      = DateTime.Today;
                        projectEmployee.Project_Id          = new Project(projectId);
                        projectEmployee.User_Id             = new User(EMPId);

                        int response = _projectEmployeeRepository.AddNewProjectEmployee(projectEmployee);
                        if (response == 1)
                        {
                            unitOfWork.Commit();
                            return(true);
                        }
                        else
                        {
                            unitOfWork.Rollback();
                            return(false);
                        }
                    }
                    else
                    {
                        // unitOfWork.Rollback();
                        throw new EmployeeAlreadyExistException();
                    }
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
 public List <TaskExpense> GetAllExpensesForTask(string projectTaskId)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _taskExpenseRepository = new TaskExpenseRepository(unitOfWork);
             List <TaskExpense> expenses = _taskExpenseRepository.GetAllEXPsByProjectTaskId(projectTaskId);
             unitOfWork.Commit();
             return(expenses);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
 public List <ProjectTaskNormalised> GetAllTasksForProject(string projectId)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _projectTaskRepository = new ProjectTaskRepository(unitOfWork);
             List <ProjectTaskNormalised> projectList = _projectTaskRepository.GetAllTasksForProject(projectId);
             unitOfWork.Commit();
             return(projectList);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
 public List <User> GetAllClients()
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _userRepository = new UserRepository(unitOfWork);
             List <User> list = _userRepository.GetAllUsers();
             unitOfWork.Commit();
             return(list);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
 public List <ProjectWithClient> LoadAllProjects()
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _projectRepository = new ProjectRepository(unitOfWork);
             List <ProjectWithClient> projectWithClients = _projectRepository.GetAllProjects();
             unitOfWork.Commit();
             return(projectWithClients);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
Exemple #11
0
 public List <Asset> GetAllAssets()
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _assetRepository = new AssetRepository(unitOfWork);
             List <Asset> assets = _assetRepository.GetAllAssets();
             unitOfWork.Commit();
             return(assets);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
 public List <User> SearchUserByName(string name)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _userRepository = new UserRepository(unitOfWork);
             List <User> list = _userRepository.SearchUserByName(name, StaticResource.UseType.CLIENT_USER);
             unitOfWork.Commit();
             return(list);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
Exemple #13
0
 public List <User> SearchEmployeeByName(string text)
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _userRepository = new UserRepository(unitOfWork);
             List <User> searchUserByNameList =
                 _userRepository.SearchUserByName(text, StaticResource.UseType.EMPLOYEE_USER);
             unitOfWork.Commit();
             return(searchUserByNameList);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
Exemple #14
0
 public List <User> GetAllUsers()
 {
     using (DalSession dalSession = new DalSession())
     {
         UnitOfWork unitOfWork = dalSession.UnitOfWork();
         unitOfWork.Begin();
         try
         {
             _userRepository = new UserRepository(unitOfWork);
             List <User> allUsers = _userRepository.GetAllUsers();
             Console.WriteLine("allUsers {0}", allUsers);
             unitOfWork.Commit();
             return(allUsers);
         }
         catch
         {
             unitOfWork.Rollback();
             throw;
         }
     }
 }
        public List <Employee> SearchUserProject(string text)
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();
                try
                {
                    _employeeRepo = new EmployeeRepo(unitOfWork);
                    List <Employee> searchEmpByData = _employeeRepo.SearchEMPByData(text);

                    unitOfWork.Commit();
                    return(searchEmpByData);
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
Exemple #16
0
        public List <Employee> GetAllEmp()
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();
                try
                {
                    _employeeRepo = new EmployeeRepo(unitOfWork);
                    List <Employee> allEmPs = _employeeRepo.GetAllEMPs();

                    unitOfWork.Commit();
                    return(allEmPs);
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
Exemple #17
0
        public bool CheckUsernamePassword(Admin admin)
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();

                try
                {
                    adminRepository = new AdminRepository(unitOfWork);
                    int res = adminRepository.CheckUsernamePassword(admin);
                    Console.WriteLine("res >>> {0}", res);
                    unitOfWork.Commit();
                    return(res == 1);
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
Exemple #18
0
        public bool AddAssetExpense(TaskAssetExpense taskAssetExpense)
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();
                try
                {
                    _taskAssetExpenseRepository                  = new TaskAssetExpenseRepository(unitOfWork);
                    _taskExpenseRepository                       = new TaskExpenseRepository(unitOfWork);
                    taskAssetExpense.Task_Asset_Expense_Id       = Guid.NewGuid().ToString();
                    taskAssetExpense.TaskExpense.Task_Expense_Id = Guid.NewGuid().ToString();

                    if (_taskExpenseRepository.addNewTaskExpense(taskAssetExpense.TaskExpense) == 1)
                    {
                        if (_taskAssetExpenseRepository.addNewTaskAssetExpense(taskAssetExpense) == 1)
                        {
                            unitOfWork.Commit();
                            return(true);
                        }
                        else
                        {
                            unitOfWork.Rollback();
                            return(false);
                        }
                    }
                    else
                    {
                        unitOfWork.Rollback();
                        return(false);
                    }
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
Exemple #19
0
        public TotalDetail GetTotalDetails()
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();
                try
                {
                    _projectRepository       = new ProjectRepository(unitOfWork);
                    _employeeRepo            = new EmployeeRepo(unitOfWork);
                    _assetRepository         = new AssetRepository(unitOfWork);
                    _taskExpenseRepository   = new TaskExpenseRepository(unitOfWork);
                    _projectIncomeRepository = new ProjectIncomeRepository(unitOfWork);

                    TotalDetail totalDetail = new TotalDetail();
                    totalDetail.TotalProject   = _projectRepository.GetTotalProjects();
                    totalDetail.TotalEmployees = _employeeRepo.GetTotalEmployees();
                    totalDetail.TotalAssets    = _assetRepository.GetTotalAssets();
                    totalDetail.TotalIncome    =
                        _projectIncomeRepository.GetTotalProjectIncomesByMonthAndYear(
                            DateTime.Now.Month.ToString(),
                            DateTime.Now.Year.ToString()
                            );

                    totalDetail.TotalExpenses = _taskExpenseRepository.GetTotalProjectTasksExsByMonthAndYear(
                        DateTime.Now.Month.ToString(),
                        DateTime.Now.Year.ToString()
                        );

                    unitOfWork.Commit();
                    return(totalDetail);
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
        public List <ProjectEmployeeExpanded> GetAllEmployeesForProject(string projectId)
        {
            using (DalSession dalSession = new DalSession())
            {
                UnitOfWork unitOfWork = dalSession.UnitOfWork();
                unitOfWork.Begin();
                try
                {
                    // _projectRepository = new ProjectRepository(unitOfWork);
                    _projectEmployeeRepository = new ProjectEmployeeRepository(unitOfWork);
                    List <ProjectEmployeeExpanded> allAssignedEmployeesByProjectId =
                        _projectEmployeeRepository.GetAllAssignedEmployeesByProjectId(projectId);

                    unitOfWork.Commit();
                    return(allAssignedEmployeesByProjectId);
                }
                catch
                {
                    unitOfWork.Rollback();
                    throw;
                }
            }
        }
Exemple #21
0
        public int AddNewEmployee(User user, StaticResource.UseType useType)
        {
            if (useType == StaticResource.UseType.EMPLOYEE_USER)
            {
                using (DalSession dalSession = new DalSession())
                {
                    UnitOfWork unitOfWork = dalSession.UnitOfWork();
                    unitOfWork.Begin();

                    try
                    {
                        user.User_Id  = Guid.NewGuid().ToString();
                        _employeeRepo = new EmployeeRepo(unitOfWork);
                        if (_employeeRepo.AddEMP((Employee)user) == 1)
                        {
                            unitOfWork.Commit();
                            return(1);
                        }
                        else
                        {
                            unitOfWork.Rollback();
                            return(0);
                        }
                    }
                    catch
                    {
                        unitOfWork.Rollback();
                        throw;
                    }
                }
            }
            else if (useType == StaticResource.UseType.ADMIN_USER)
            {
                using (DalSession dalSession = new DalSession())
                {
                    UnitOfWork unitOfWork = dalSession.UnitOfWork();
                    unitOfWork.Begin();

                    try
                    {
                        user.User_Id     = Guid.NewGuid().ToString();
                        _adminRepository = new AdminRepository(unitOfWork);
                        if (_adminRepository.AddAdminUser((AdminUser)user) == 1)
                        {
                            unitOfWork.Commit();
                            return(1);
                        }
                        else
                        {
                            unitOfWork.Rollback();
                            return(0);
                        }
                    }
                    catch
                    {
                        unitOfWork.Rollback();
                        throw;
                    }
                }
            }
            else if (useType == StaticResource.UseType.CLIENT_USER)
            {
                using (DalSession dalSession = new DalSession())
                {
                    UnitOfWork unitOfWork = dalSession.UnitOfWork();
                    unitOfWork.Begin();

                    try
                    {
                        user.User_Id      = Guid.NewGuid().ToString();
                        _clientRepository = new ClientRepository(unitOfWork);
                        if (_clientRepository.AddClient((Client)user) == 1)
                        {
                            unitOfWork.Commit();
                            return(1);
                        }
                        else
                        {
                            unitOfWork.Rollback();
                            return(0);
                        }
                    }
                    catch
                    {
                        unitOfWork.Rollback();
                        throw;
                    }
                }
            }
            else
            {
                throw new System.Exception();
            }
        }