Exemplo n.º 1
0
        public void CreateAnt(QueenViewModel objVM)
        {
            // Validating age
            var  ageValidator = new AgeValidator();
            bool isAgeCorrect = ageValidator.Validate(objVM.AntAge, objVM.AntType);

            if (isAgeCorrect == true)
            {
                // Mapping ViewModel -> DomainModel
                var objDM = new QueenDomainModel();

                objDM.Id      = objVM.Id;
                objDM.AntName = objVM.AntName;
                objDM.AntType = objVM.AntType;
                objDM.AntAge  = objVM.AntAge;

                this._antRepo.CreateAnt(objDM);
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            var queenAkasha = new QueenViewModel();

            queenAkasha.Id      = 6;
            queenAkasha.AntName = "Akasha4";
            queenAkasha.AntType = Models.BaseModels.AntType.Queen;
            queenAkasha.AntAge  = 7;

            // Adding record without generic
            antController.CreateAnt(queenAkasha);


            var queenDiana = new QueenViewModel();

            queenDiana.Id      = 7;
            queenDiana.AntName = "Diana";
            queenDiana.AntType = AntType.Queen;
            queenDiana.AntAge  = 18;

            // Adding record with generic
            antGenericController.CreateAnt(queenDiana);
        }
Exemplo n.º 3
0
 public void CreateAnt(QueenViewModel objVM)
 {
     this._antService.CreateAnt(objVM);
 }