public IEnumerable <Transaction> GetByCondition_BCCP(DateTime fromDate, DateTime toDate, int districtId, int poId, string currentUser)
        {
            int bccpId = 1;
            // define role of user name
            bool isAdmin   = _userRepository.CheckRole(currentUser, "Administrator");
            bool isManager = _userRepository.CheckRole(currentUser, "Manager");
            bool isSupport = _userRepository.CheckRole(currentUser, "Support");

            if (isAdmin || isSupport) //is admin
            {
                if (districtId == 0)
                {
                    return(_transactionRepository.GetAllByMainGroupId(fromDate, toDate, bccpId));
                }
                else
                {
                    if (poId == 0)
                    {
                        return(_transactionRepository.GetAllBy_Time_DistrictID_MainGroupId(fromDate, toDate, districtId, bccpId));
                    }
                    else // po id and district id not null
                    {
                        return(_transactionRepository.GetAllBy_Time_DistrictID_POID_MainGroupId(fromDate, toDate, districtId, poId, bccpId));
                    }
                }
            }
            else
            {
                if (isManager) // is manager
                {
                    if (poId == 0)
                    {
                        districtId = _districtRepository.GetDistrictByUserName(currentUser).ID;
                        return(_transactionRepository.GetAllBy_Time_DistrictID_MainGroupId(fromDate, toDate, districtId, bccpId));
                    }
                    else // po id and district id not null
                    {
                        districtId = _districtRepository.GetDistrictByUserName(currentUser).ID;
                        return(_transactionRepository.GetAllBy_Time_DistrictID_POID_MainGroupId(fromDate, toDate, districtId, poId, bccpId));
                    }
                }
                else
                {
                    string userId = _userRepository.getByUserName(currentUser).Id;
                    poId       = _userRepository.getByUserName(currentUser).POID;
                    districtId = _districtRepository.GetDistrictByUserName(currentUser).ID;
                    return(_transactionRepository.GetAllBy_Time_DistrictID_POID_UserId_MainGroupId(fromDate, toDate, districtId, poId, userId, bccpId));
                }
            }
        }
Exemple #2
0
 public bool CheckRole(string userName, string roleName)
 {
     return(_userRepository.CheckRole(userName, roleName));
 }
Exemple #3
0
        public IEnumerable <Export_By_Service_Group_And_Time> Export_By_Service_Group_And_Time(string fromDate, string toDate, int mainGroup, int districtId, int poId, string currentUser)
        {
            bool isAdmin   = _userRepository.CheckRole(currentUser, "Administrator");
            bool isManager = _userRepository.CheckRole(currentUser, "Manager");

            var    user   = _userRepository.getByUserName(currentUser);
            string userId = null;

            if (user != null)
            {
                userId = user.Id;
            }

            if (isAdmin)
            {
                if (districtId == 0)
                {
                    return(_statisticRepository.Export_By_Service_Group_And_Time(fromDate, toDate, mainGroup));
                }
                else
                {
                    if (poId == 0)
                    {
                        return(_statisticRepository.Export_By_Service_Group_And_Time_District(fromDate, toDate, mainGroup, districtId));
                    }
                    else
                    {
                        return(_statisticRepository.Export_By_Service_Group_And_Time_District_Po(fromDate, toDate, mainGroup, districtId, poId));
                    }
                }
            }
            else
            {
                if (isManager)
                {
                    if (poId == 0)
                    {
                        return(_statisticRepository.Export_By_Service_Group_And_Time_District(fromDate, toDate, mainGroup, districtId));
                    }
                    else
                    {
                        return(_statisticRepository.Export_By_Service_Group_And_Time_District_Po(fromDate, toDate, mainGroup, districtId, poId));
                    }
                }
                else
                {
                    return(_statisticRepository.Export_By_Service_Group_And_Time_User(fromDate, toDate, mainGroup, userId));
                }
            }
        }
        public IEnumerable <TKBD_History_Statistic> Get_By_Condition(string fromDate, string toDate, int districtId, int poId, string currentUser, string userSelected)
        {
            // define role of user
            bool isAdmin   = _userRepository.CheckRole(currentUser, "Administrator");
            bool isManager = _userRepository.CheckRole(currentUser, "Manager");

            //get user info
            var    user          = _userRepository.getByUserId(userSelected);
            var    currentUserId = _userRepository.getByUserName(currentUser).Id;
            string userId        = null;

            if (user != null)
            {
                userId = user.Id;
            }

            if (isAdmin) //is admin
            {
                if (districtId == 0)
                {
                    return(_tkbdRepository.Get_By_Time(fromDate, toDate));
                }
                else
                {
                    if (poId == 0)
                    {
                        return(_tkbdRepository.Get_By_Time_District(fromDate, toDate, districtId));
                    }
                    else // po id and district id not null
                    {
                        if (user == null) //po && district are not null && user null
                        {
                            return(_tkbdRepository.Get_By_Time_District_Po(fromDate, toDate, districtId, poId));
                        }
                        else // po && district && user are not null
                        {
                            return(_tkbdRepository.Get_By_Time_District_Po_User(fromDate, toDate, districtId, poId, userId));
                        }
                    }
                }
            }
            else
            {
                if (isManager) // is manager
                {
                    if (poId == 0)
                    {
                        return(_tkbdRepository.Get_By_Time_District(fromDate, toDate, districtId));
                    }
                    else // po id and district id not null
                    {
                        if (userId == null) //po && district are not null && user null
                        {
                            return(_tkbdRepository.Get_By_Time_District_Po(fromDate, toDate, districtId, poId));
                        }
                        else // po && district && user are not null
                        {
                            return(_tkbdRepository.Get_By_Time_District_Po_User(fromDate, toDate, districtId, poId, userId));
                        }
                    }
                }
                else //is basic user
                {
                    return(_tkbdRepository.Get_By_Time_User(fromDate, toDate, currentUserId));
                }
            }
        }
Exemple #5
0
        public IEnumerable <TKBD_Export_Template> Export_TKBD_By_Condition(int month, int year, int districtId, int poId, string currentUser, string userSelected)
        {
            // define role of user
            bool isAdmin   = _userRepository.CheckRole(currentUser, "Administrator");
            bool isManager = _userRepository.CheckRole(currentUser, "Manager");

            //get user info
            var    currentUserId = _userRepository.getByUserName(currentUser).Id;
            var    user          = _userRepository.getByUserId(userSelected);
            string userId        = null;

            if (user != null)
            {
                userId = user.Id;
            }

            if (isAdmin) //is admin
            {
                if (districtId == 0)
                {
                    return(_tKBDRepository.Export_By_Time(month, year));
                }
                else
                {
                    if (poId == 0)
                    {
                        return(_tKBDRepository.Export_By_Time_District(month, year, districtId));
                    }
                    else // po id and district id not null
                    {
                        if (user == null) //po && district are not null && user null
                        {
                            return(_tKBDRepository.Export_By_Time_District_Po(month, year, districtId, poId));
                        }
                        else // po && district && user are not null
                        {
                            return(_tKBDRepository.Export_By_Time_District_Po_User(month, year, districtId, poId, userSelected));
                        }
                    }
                }
            }
            else
            {
                if (isManager) // is manager
                {
                    if (poId == 0)
                    {
                        return(_tKBDRepository.Export_By_Time_District(month, year, districtId));
                    }
                    else // po id and district id not null
                    {
                        if (userId == null) //po && district are not null && user null
                        {
                            return(_tKBDRepository.Export_By_Time_District_Po(month, year, districtId, poId));
                        }
                        else // po && district && user are not null
                        {
                            return(_tKBDRepository.Export_By_Time_District_Po_User(month, year, districtId, poId, userSelected));
                        }
                    }
                }
                else //is basic user
                {
                    return(_tKBDRepository.Export_By_Time_User(month, year, currentUserId));
                }
            }
        }