Exemple #1
0
        protected List <AgencyInfo> GetStaffC1(HaiStaff staff)
        {
            List <AgencyInfo> agencyResult = new List <AgencyInfo>();

            List <C1Info> c1List = new List <C1Info>();

            int permit = HaiUtil.CheckRoleShowInfo(db, User.Identity.Name);

            if (permit == 2)
            {
                // get list cn
                var branchPermit = db.UserBranchPermisses.Where(p => p.UserName == User.Identity.Name).Select(p => p.BranchCode).ToList();
                c1List = db.C1Info.Where(p => branchPermit.Contains(p.CInfoCommon.BranchCode)).ToList();
            }
            else
            {
                c1List = staff.C1Info.Where(p => p.IsActive == 1).OrderBy(p => p.CInfoCommon.BranchCode).ToList();
            }

            foreach (var item in c1List)
            {
                agencyResult.Add(new AgencyInfo()
                {
                    code            = item.Code,
                    name            = item.StoreName,
                    type            = "CI",
                    deputy          = item.Deputy,
                    address         = item.CInfoCommon.AddressInfo,
                    lat             = item.CInfoCommon.Lat == null ? 0 : item.CInfoCommon.Lat,
                    lng             = item.CInfoCommon.Lng == null ? 0 : item.CInfoCommon.Lng,
                    phone           = item.CInfoCommon.Phone,
                    id              = item.CInfoCommon.Id,
                    rank            = item.CInfoCommon.CRank,
                    group           = "CI",
                    identityCard    = item.CInfoCommon.IdentityCard,
                    businessLicense = item.CInfoCommon.BusinessLicense,
                    province        = item.CInfoCommon.ProvinceName,
                    district        = item.CInfoCommon.DistrictName,
                    taxCode         = item.CInfoCommon.TaxCode,
                    haibranch       = item.CInfoCommon.BranchCode,
                    subOwner        = new List <SubOwner>()
                });
            }

            return(agencyResult);
        }
Exemple #2
0
        protected List <AgencyInfo> GetStaffC2(HaiStaff staff)
        {
            List <AgencyInfo> agencyResult = new List <AgencyInfo>();

            List <C2Info> c2List = new List <C2Info>();

            int permit = HaiUtil.CheckRoleShowInfo(db, User.Identity.Name);

            if (permit == 2)
            {
                // get list cn
                var branchPermit = db.UserBranchPermisses.Where(p => p.UserName == User.Identity.Name).Select(p => p.BranchCode).ToList();
                c2List = db.C2Info.Where(p => branchPermit.Contains(p.CInfoCommon.BranchCode) && p.OldData == 0).ToList();
            }
            else
            {
                c2List = staff.StaffWithC2.Where(p => p.C2Info.IsActive == 1).OrderByDescending(p => p.GroupChoose).Select(p => p.C2Info).ToList();
            }

            foreach (var item in c2List)
            {
                var staffC2 = staff.StaffWithC2.Where(p => p.C2Id == item.Id).FirstOrDefault();
                int?group   = 0;
                if (staffC2 != null)
                {
                    group = staffC2.GroupChoose;
                }

                // danh sach c1
                var             c2c1       = db.C2C1.Where(p => p.C2Code == item.Code).ToList();
                List <SubOwner> agencyC2C1 = new List <SubOwner>();

                foreach (var item2 in c2c1)
                {
                    var checkC1 = db.C1Info.Where(p => p.Code == item2.C1Code).FirstOrDefault();
                    if (checkC1 != null)
                    {
                        agencyC2C1.Add(new SubOwner()
                        {
                            code     = checkC1.Code,
                            name     = checkC1.Deputy,
                            store    = checkC1.StoreName,
                            priority = item2.Priority
                        });
                    }
                }

                agencyResult.Add(new AgencyInfo()
                {
                    code            = item.Code,
                    name            = item.StoreName,
                    type            = "CII",
                    smsCode         = item.SMSCode,
                    deputy          = item.Deputy,
                    address         = item.CInfoCommon.AddressInfo,
                    lat             = item.CInfoCommon.Lat == null ? 0 : item.CInfoCommon.Lat,
                    lng             = item.CInfoCommon.Lng == null ? 0 : item.CInfoCommon.Lng,
                    phone           = item.CInfoCommon.Phone,
                    id              = item.CInfoCommon.Id,
                    rank            = item.CInfoCommon.CRank,
                    group           = Convert.ToString(group),
                    identityCard    = item.CInfoCommon.IdentityCard,
                    businessLicense = item.CInfoCommon.BusinessLicense,
                    province        = item.CInfoCommon.ProvinceName,
                    district        = item.CInfoCommon.DistrictName,
                    taxCode         = item.CInfoCommon.TaxCode,
                    haibranch       = item.CInfoCommon.BranchCode,
                    subOwner        = agencyC2C1
                });
            }

            return(agencyResult);
        }