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)); }
public async Task UpdateUserProfileAsync(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; await _db.SaveChangesAsync(); }