示例#1
0
        public ResultHandler <TrainerDto> Create(TrainerDto trainerDto)
        {
            ResultHandler <TrainerDto> resultHandler = new ResultHandler <TrainerDto>();

            try
            {
                Trainer trainer = _trainer.Create(trainerDto.FirstName, trainerDto.LastName, trainerDto.Description, trainerDto.PayRate, trainerDto.IsActive);
                _trainerRepository.Create(trainer);
                resultHandler.Data = AutoMapper.Mapper.Map <Trainer, TrainerDto>(trainer);
            }
            catch (Exception ex)
            {
                resultHandler.Errors.Add(ex.Message);
            }

            return(resultHandler);
        }