Exemple #1
0
        public List <FrayteCustomerStaff> GetCustomerStaff(FrayteCustomerStaffTrack track)
        {
            List <FrayteCustomerStaff> staff = new List <FrayteCustomerStaff>();

            FrayteOperationZone OperationZone = UtilityRepository.GetOperationZone();

            int SkipRows = 0;

            SkipRows = (track.CurrentPage - 1) * track.TakeRows;

            if (track.RoleId == (int)FrayteUserRole.Admin || track.RoleId == (int)FrayteUserRole.Staff)
            {
                staff = (from u in dbContext.Users
                         join uaa in dbContext.UserAdditionals on u.UserId equals uaa.UserId
                         join ur in dbContext.UserRoles on u.UserId equals ur.UserId
                         join ua in dbContext.UserAddresses on ur.UserId equals ua.UserId
                         join c in dbContext.Countries on ua.CountryId equals c.CountryId
                         where u.IsActive == true &&
                         u.OperationZoneId == OperationZone.OperationZoneId &&
                         ur.RoleId == (int)FrayteUserRole.CustomerStaff
                         select new FrayteCustomerStaff
                {
                    UserId = u.UserId,
                    ContactName = u.ContactName,
                    Email = u.Email,
                    PhoneNo = u.PhoneNumber,
                    TotalRows = 0,
                    Country = new FrayteCountryCode()
                    {
                        CountryId = c.CountryId,
                        Name = c.CountryName,
                        Code = c.CountryCode,
                        Code2 = c.CountryCode2,
                        CountryPhoneCode = c.CountryPhoneCode,
                    }
                }).ToList();

                int total = staff.Count();

                staff = staff.OrderBy(p => p.UserId).Skip(SkipRows).Take(track.TakeRows).ToList();

                staff.ForEach(p => p.TotalRows = total);
            }
            else if (track.RoleId == (int)FrayteUserRole.Customer)
            {
                staff = (from u in dbContext.Users
                         join ur in dbContext.UserRoles on u.UserId equals ur.UserId
                         join ua in dbContext.UserAddresses on ur.UserId equals ua.UserId
                         join c in dbContext.Countries on ua.CountryId equals c.CountryId
                         join cs in dbContext.CustomerStaffs on u.UserId equals cs.CustomerStaffId
                         where u.IsActive == true &&
                         u.OperationZoneId == OperationZone.OperationZoneId &&
                         ur.RoleId == (int)FrayteUserRole.CustomerStaff &&
                         cs.UserId == track.CreatedBy &&
                         cs.IsActive == true
                         select new FrayteCustomerStaff
                {
                    UserId = u.UserId,
                    ContactName = u.ContactName,
                    Email = u.Email,
                    PhoneNo = u.PhoneNumber,
                    TotalRows = 0,
                    Country = new FrayteCountryCode()
                    {
                        CountryId = c.CountryId,
                        Name = c.CountryName,
                        Code = c.CountryCode,
                        Code2 = c.CountryCode2,
                        CountryPhoneCode = c.CountryPhoneCode,
                    }
                }).ToList();

                int total = staff.Count();

                staff = staff.OrderBy(p => p.UserId).Skip(SkipRows).Take(track.TakeRows).ToList();

                staff.ForEach(p => p.TotalRows = total);
            }
            return(staff);
        }
Exemple #2
0
        public List <FrayteCustomerStaff> GetInitials(FrayteCustomerStaffTrack track)
        {
            List <FrayteCustomerStaff> staff = new CustomerStaffRepository().GetCustomerStaff(track);

            return(staff);
        }