コード例 #1
0
 public SalesRepresentative CreateSalesRepresentative(FranchiseeFranchiseeUserRow franchiseeFranchiseeUserViewRow,
                                                      User user)
 {
     if (franchiseeFranchiseeUserViewRow == null)
     {
         throw new ArgumentNullException("franchiseeFranchiseeUserViewRow");
     }
     if (user == null)
     {
         throw new ArgumentNullException("user");
     }
     return(new SalesRepresentative(user.Id)
     {
         SalesRepresentativeId = franchiseeFranchiseeUserViewRow.OrganizationRoleUserId,
         FranchiseeId = franchiseeFranchiseeUserViewRow.OrganizationId,
         Name = user.Name
     });
 }
コード例 #2
0
        public List <SalesRepresentative> CreateSalesRepresentatives(FranchiseeFranchiseeUserTypedView
                                                                     franchiseeFranchiseeUserViewTypedView, List <User> users)
        {
            if (franchiseeFranchiseeUserViewTypedView == null)
            {
                throw new ArgumentNullException("franchiseeFranchiseeUserViewTypedView");
            }
            if (users == null)
            {
                throw new ArgumentNullException("users");
            }
            var salesRepresentatives = new List <SalesRepresentative>();

            foreach (FranchiseeFranchiseeUserRow franchiseeFranchiseeUserViewRow in franchiseeFranchiseeUserViewTypedView)
            {
                FranchiseeFranchiseeUserRow row = franchiseeFranchiseeUserViewRow;
                var user = users.Where(u => u.Id == row.UserId).SingleOrDefault();
                if (user != null)
                {
                    SalesRepresentative salesRepresentative;
                    try
                    {
                        salesRepresentative = CreateSalesRepresentative(franchiseeFranchiseeUserViewRow, user);
                    }
                    catch (InvalidOperationException)
                    {
                        throw new InvalidOperationException(string.Format(
                                                                "User for sales representative {0} not given.",
                                                                franchiseeFranchiseeUserViewRow.
                                                                OrganizationRoleUserId));
                    }
                    salesRepresentatives.Add(salesRepresentative);
                }
            }
            return(salesRepresentatives);
        }