コード例 #1
0
        // GET: api/BrandInfoes
        public List <Models.BrandInfo> GetBrandInfoes()
        {
            List <Models.BrandInfo> brandInfos = new List <Models.BrandInfo>();

            foreach (Data.BrandInfo brandinfo in db.BrandInfoes)
            {
                Models.BrandInfo brandInfoModel = new Models.BrandInfo
                {
                    id                = brandinfo.id,
                    userId            = brandinfo.userId,
                    brandId           = brandinfo.brandId,
                    brandName         = brandinfo.brandName,
                    branchId          = brandinfo.branchId,
                    branchName        = brandinfo.branchName,
                    departmentId      = brandinfo.departmentId,
                    departmentName    = brandinfo.departmentName,
                    departmentManager = brandinfo.departmentManager,
                    workingHoursStart = brandinfo.workingHoursStart,
                    workingHoursEnd   = brandinfo.workingHoursEnd,
                    branches          = new List <IdText>(),
                    departments       = new List <IdText>()
                };
                brandInfoModel.branches.Add(new IdText {
                    id = brandinfo.Branch.branchId, text = brandinfo.Branch.branchName
                });
                brandInfoModel.departments.Add(new IdText {
                    id = brandinfo.Department.departmentId, text = brandinfo.Department.departmentName
                });
                brandInfoModel.departments.Add(new IdText {
                    id = 2, text = "Sales"
                });
                brandInfoModel.departments.Add(new IdText {
                    id = 3, text = "Marketing"
                });
                brandInfoModel.departments.Add(new IdText {
                    id = 4, text = "Compliance"
                });
                brandInfos.Add(brandInfoModel);
            }

            return(brandInfos);
        }
コード例 #2
0
ファイル: UsersController.cs プロジェクト: sanbish/Projects
        public List <Users> GetUsers()
        {
            List <Users>            Users = new List <Users>();
            List <Models.BrandInfo> brandInfos;
            var allUsers = db.Users.Include(b => b.BrandInfoes);

            foreach (User User in allUsers)
            {
                Users tempUser = new Users();
                tempUser.userId            = User.userId;
                tempUser.memebershipUserId = User.memebershipUserId;
                tempUser.userName          = User.userName;
                tempUser.email             = User.email;
                tempUser.password          = User.password;
                tempUser.profilePicture    = User.profilePicture;
                tempUser.signturePicture   = User.signturePicture;
                tempUser.firstName         = User.firstName;
                tempUser.lastName          = User.lastName;
                tempUser.fullName          = User.fullName;
                tempUser.phoneNumber       = User.phoneNumber;
                tempUser.gender            = User.gender;
                tempUser.birthday          = User.birthday.ToString("dd/MM/yyyy");
                tempUser.memberSince       = User.memberSince.ToString("dd/MM/yyyy");
                tempUser.location          = User.location;
                tempUser.languageId        = User.languageId;
                tempUser.languageName      = User.languageName;
                tempUser.position          = User.position;
                tempUser.job                    = User.job;
                tempUser.voIpExtension          = User.voIpExtension;
                tempUser.voIpSip                = User.voIpSip;
                tempUser.promoCode              = User.promoCode;
                tempUser.depositSmsNotification = User.depositSmsNotification;
                tempUser.enabled                = User.enabled;
                tempUser.isOnline               = User.isOnline;
                brandInfos = new List <Models.BrandInfo>();
                foreach (Data.BrandInfo brandinfo in User.BrandInfoes)
                {
                    Models.BrandInfo brandInfoModel = new Models.BrandInfo
                    {
                        id                = brandinfo.id,
                        userId            = brandinfo.userId,
                        brandId           = brandinfo.brandId,
                        brandName         = brandinfo.branchName,
                        branchId          = brandinfo.branchId,
                        branchName        = brandinfo.branchName,
                        departmentId      = brandinfo.departmentId,
                        departmentName    = brandinfo.departmentName,
                        departmentManager = brandinfo.departmentManager,
                        workingHoursStart = brandinfo.workingHoursStart,
                        workingHoursEnd   = brandinfo.workingHoursEnd,
                        branches          = new List <IdText>(),
                        departments       = new List <IdText>()
                    };
                    brandInfoModel.branches.Add(new IdText {
                        id = brandinfo.Branch.branchId, text = brandinfo.Branch.branchName
                    });
                    brandInfoModel.departments.Add(new IdText {
                        id = brandinfo.Department.departmentId, text = brandinfo.Department.departmentName
                    });
                    brandInfos.Add(brandInfoModel);
                }
                tempUser.BrandInfoes = brandInfos;
                Users.Add(tempUser);
            }
            return(Users);
        }