Exemple #1
0
        /// <summary>
        /// This gets the super salesman category.
        /// </summary>
        /// <returns></returns>
        private SalesmanCategory getSuperSalesmanCategory()
        {
            SalesmanCategory sc = SalesmanCategoryBiz.FindByName(SalesmanCategoryENUM.SuperSalesman.ToString().ToTitleSentance());

            sc.IsNullThrowException();
            return(sc);
        }
Exemple #2
0
 /// <summary>
 /// We are getting "Super Salesman" from this basicaly.
 /// </summary>
 void initializeSalesmanCategories()
 {
     foreach (var item in Enum.GetNames(SalesmanCategoryENUM.Unknown.GetType()))
     {
         string nameFixed = item.ToTitleSentance();
         if (nameFixed.IsNullOrWhiteSpace())
         {
             continue;
         }
         //see if it already exists
         SalesmanCategory sc = FindForName(nameFixed);
         if (sc.IsNull())
         {
             sc      = Factory() as SalesmanCategory;
             sc.Name = nameFixed;
             CreateAndSave(sc);
         }
     }
 }
Exemple #3
0
        private void only_super_Salesman_Can_Be_Parent(Salesman salesman)
        {
            //CHECK parent is Super salesman
            if (salesman.ParentSalesmanId.IsNullOrWhiteSpace())
            {
                return;
            }
            //check to see if Parent is a super Salesman category
            if (salesman.ParentSalesman.IsNull())
            {
                salesman.ParentSalesman = Find(salesman.ParentSalesmanId);
            }
            salesman.ParentSalesman.IsNullThrowException("Unable to locate Salesman");

            SalesmanCategory sc = getSuperSalesmanCategory();

            if (salesman.ParentSalesman.SalesmanCategoryId != sc.Id)
            {
                string err = string.Format("The salesman '{0}' is not a Super Salesman and therefore CANNOT be a parent.", salesman.ParentSalesman.FullName());
                throw new Exception(err);
            }
        }