public DepartmentProfile GetOrInitializeDepartmentProfile(int departmentId) { DepartmentProfile profile = GetDepartmentProfileByDepartmentId(departmentId); if (profile != null) { return(profile); } Department department = _departmentsService.GetDepartmentById(departmentId); profile = new DepartmentProfile(); profile.Code = $"{RandomGenerator.CreateCode(2)}-{RandomGenerator.CreateCode(4)}"; profile.DepartmentId = departmentId; profile.Name = department.Name; var mapCenterGpsCoordinates = _departmentSettingsService.GetBigBoardCenterGpsCoordinatesDepartment(departmentId); if (!String.IsNullOrWhiteSpace(mapCenterGpsCoordinates)) { string[] coordinates = mapCenterGpsCoordinates.Split(char.Parse(",")); if (coordinates.Count() == 2) { profile.Latitude = coordinates[0]; profile.Longitude = coordinates[1]; } } else { profile.AddressId = department.AddressId; } return(SaveDepartmentProfile(profile)); }
public DepartmentProfile SaveDepartmentProfile(DepartmentProfile profile) { _departmentProfileRepository.SaveOrUpdate(profile); return(profile); }