public async Task <SessionModelResponse> AddOrUpdateSession(SessionModelRequest session) { _sessionRepository.DeleteServiceFromSession(session.Id); int id = await _sessionRepository.AddOrUpdateSession(Mapper.Map <DalSessionModelRequest>(session)); if (session.ServiceIds != null) { foreach (var service in session.ServiceIds) { DalSessionServiceModel sessionService = new DalSessionServiceModel(session.Id, service); _sessionRepository.AddServiceToSession(sessionService); } } return(await GetSessionById(session.Id) ?? throw new InvalidOperationException()); }