Exemple #1
0
        public PersonalReadDto Create(PersonalCreateDto dto)
        {
            var personal = _mapper.Map <Personal>(dto);

            _context.Personal.Add(personal);

            _context.SaveChanges();

            _logger.Log("Personal created!");

            return(_mapper.Map <PersonalReadDto>(personal));
        }
        public UserReadDto Create(UserCreateDto dto)
        {
            var user = _mapper.Map <User>(dto);

            _context.Users.Add(user);

            _context.SaveChanges();

            _logger.Log("User created!");

            return(_mapper.Map <UserReadDto>(user));
        }
        public AdministratorReadDto Create(AdministratorCreateDto dto)
        {
            var admin = _mapper.Map <Administrator>(dto);

            _context.Administrators.Add(admin);

            _context.SaveChanges();

            _logger.Log("Admin created!");

            return(_mapper.Map <AdministratorReadDto>(admin));
        }
        public CorporateReadDto Create(CorporateCreateDto dto)
        {
            var corporate = _mapper.Map <Corporate>(dto);

            var owner = _context.Users.FirstOrDefault(e => e.Id == dto.OwnerId);

            if (owner == null)
            {
                throw new BusinessException("Owner does not exist", 400);
            }

            _context.Corporators.Add(corporate);

            _context.SaveChanges();

            _logger.Log("Corporate created!");

            return(_mapper.Map <CorporateReadDto>(corporate));
        }