Exemple #1
0
        public async Task <User> RegisterAsync(User user)
        {
            City city = await _cityLogic.GetCityByNameAsync(user.City.CityName);

            if (city == null)
            {
                city = await _cityLogic.AddCityAsync(user.City.CityName);

                user.CityId = city.CityId;
                user.City   = city;
            }
            else
            {
                user.CityId = city.CityId;
                user.City   = city;
            }

            Department department = await _departmentLogic.GetDepartmentByNameAsync(user.Department.DepartmentName);

            user.DepartmentId   = department.DepartmentId;
            user.Department     = department;
            user.HashedPassword = GetHashedPassword(user.Email, user.HashedPassword);
            Role role = await _roleLogic.GetDefaultRoleAsync();

            user.RoleId = role.RoleId;
            user.Role   = role;
            Image image = await _imageLogic.GetDefaultUserImageAsync();

            user.ImageId = image.ImageId;
            user.Image   = image;

            return(await _userLogic.AddUserAsync(user));
        }