Esempio n. 1
0
        public ActionResult <UserDTO> CreateAccount(UserAuthentication userFromBody)
        {
            if (_context.Users.Any(u => u.Email == userFromBody.Email))
            {
                throw new Exception("There are an account with the same e-mail..");
            }
            var userForCreation = _mapper.Map <Users>(userFromBody);

            userForCreation.Country = RegionInfo.CurrentRegion.EnglishName;
            _context.Users.Add(userForCreation);
            _context.SaveChanges();
            return(Ok(_mapper.Map <UserDTO>(userForCreation)));
        }
 public bool Save()
 {
     return(_context.SaveChanges() >= 0);
 }