コード例 #1
0
        public override void ValidateRow(ImportRow row)
        {
            // employee id is required if its on the sheet.
            if (row.Has(UserColumnMappingTargets.EmployeeId) &&
                String.IsNullOrEmpty((string)row[UserColumnMappingTargets.EmployeeId]))
            {
                row.AddProblem("Row has an empty EmployeeId column. EmployeeId is an optional column, but if part of the upload sheet, it must be filled.");
            }

            // login is also required if on the sheet
            if (row.Has(UserColumnMappingTargets.Login) &&
                String.IsNullOrEmpty((string)row[UserColumnMappingTargets.Login]))
            {
                row.AddProblem("Row has an empty Login value. Login is a required field.");
            }
        }
コード例 #2
0
        public override Product Find(ImportRow row)
        {
            // search by employee id first
            if (row.Has(ProductColumnMappingTargets.ProductId))
            {
                return(Products.FindByProductId((string)row[ProductColumnMappingTargets.ProductId]));
            }

            row.AddProblem("Import contains no ProductId.");
            return(null);
        }
コード例 #3
0
        public override void ValidateRow(ImportRow row)
        {
            // product id is required
            if (String.IsNullOrEmpty((string)row[ProductColumnMappingTargets.ProductId]))
            {
                row.AddProblem("Row has an empty ProductId column. ProductId is a required field.");
            }

            // name is also required if on the sheet
            if (String.IsNullOrEmpty((string)row[ProductColumnMappingTargets.Name]))
            {
                row.AddProblem("Row has an empty name value. Name is a required field.");
            }

            var cost = (decimal?)row[ProductColumnMappingTargets.Cost];

            if (!cost.HasValue)
            {
                row.AddProblem("Row has no cost value. Cost is a required field.");
            }
        }
コード例 #4
0
        public override User Find(ImportRow row)
        {
            // search by employee id first
            if (row.Has(UserColumnMappingTargets.EmployeeId))
            {
                return(Users.FindUserByEmployeeId((string)row[UserColumnMappingTargets.EmployeeId]));
            }

            // search by login next
            if (row.Has(UserColumnMappingTargets.Login))
            {
                return(Users.FindUserByLogin((string)row[UserColumnMappingTargets.Login]));
            }

            row.AddProblem("Import contains neither EmployeeId nor Login.");
            return(null);
        }